fix: yaml stdio per-connection, iac catalog path, makefile port
- yaml-language-server: rewrite to stdio per WebSocket (fixes crash loop) vscode-jsonrpc v9 createServerSocketTransport is a TCP client, not server now spawns yaml-language-server --stdio per connection via asyncio subprocess - bicep/modules.py: add /iac_source_catalog.json as first path in _IAC_SOURCE_PATHS Dockerfile copies to /iac_source_catalog.json but path wasn't listed - server.py: remove YAML_LSP_PORT daemon (no longer needed with stdio mode) - Makefile: add -e HTTP_PORT=$(HEALTH_PORT) to all docker run commands server defaulted to :8000 but Makefile exposed :2089 with no override
This commit is contained in:
@@ -31,7 +31,6 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
PYTHON_LSP_PORT = int(os.getenv("PYTHON_LSP_PORT", "2087"))
|
||||
BICEP_LSP_PORT = int(os.getenv("BICEP_LSP_PORT", "2088"))
|
||||
YAML_LSP_PORT = int(os.getenv("YAML_LSP_PORT", "2090"))
|
||||
HTTP_PORT = int(os.getenv("HTTP_PORT", "8000"))
|
||||
|
||||
_CHUNK = 65536
|
||||
@@ -48,20 +47,6 @@ def _serve_python_lsp(port: int) -> None:
|
||||
logger.warning("pylsp exited (code %s) — restarting", proc.returncode)
|
||||
|
||||
|
||||
def _serve_yaml_lsp(port: int) -> None:
|
||||
"""Start yaml-language-server in TCP socket mode; restart on unexpected exit."""
|
||||
import shutil
|
||||
yaml_ls = shutil.which("yaml-language-server")
|
||||
if not yaml_ls:
|
||||
logger.warning("yaml-language-server not found — /yaml completions disabled")
|
||||
return
|
||||
while True:
|
||||
proc = subprocess.Popen([yaml_ls, f"--socket={port}"])
|
||||
logger.info("yaml-language-server listening on localhost:%d PID=%d", port, proc.pid)
|
||||
proc.wait()
|
||||
logger.warning("yaml-language-server exited (code %s) — restarting", proc.returncode)
|
||||
|
||||
|
||||
async def _pipe(reader: asyncio.StreamReader, writer) -> None:
|
||||
"""Pipe bytes from reader to writer until EOF."""
|
||||
try:
|
||||
@@ -162,7 +147,7 @@ async def _build_app() -> web.Application:
|
||||
return await _ws_proxy(request, "127.0.0.1", BICEP_LSP_PORT)
|
||||
|
||||
async def yaml_ws(request: web.Request) -> web.WebSocketResponse:
|
||||
return await yaml_ws_handler(request, YAML_LSP_PORT)
|
||||
return await yaml_ws_handler(request)
|
||||
|
||||
app.router.add_get("/health", health)
|
||||
app.router.add_post("/reload", reload)
|
||||
@@ -186,7 +171,7 @@ async def main_async() -> None:
|
||||
# LSP servers run internally on localhost — not exposed outside the container
|
||||
threading.Thread(target=_serve_python_lsp, args=(PYTHON_LSP_PORT,), daemon=True).start()
|
||||
threading.Thread(target=serve_bicep, args=(BICEP_LSP_PORT,), daemon=True).start()
|
||||
threading.Thread(target=_serve_yaml_lsp, args=(YAML_LSP_PORT,), daemon=True).start()
|
||||
# yaml-language-server is spawned per-connection in yaml_ws_handler (--stdio mode)
|
||||
|
||||
app = await _build_app()
|
||||
runner = web.AppRunner(app)
|
||||
|
||||
Reference in New Issue
Block a user