feat(gateway): allow webchat port override

This commit is contained in:
Peter Steinberger
2025-12-10 16:55:17 +00:00
parent e9fd73141d
commit 93a5784c58
4 changed files with 28 additions and 6 deletions

View File

@@ -214,6 +214,10 @@ Examples:
.command("gateway")
.description("Run the WebSocket Gateway")
.option("--port <port>", "Port for the gateway WebSocket", "18789")
.option(
"--webchat-port <port>",
"Port for the loopback WebChat HTTP server (default 18788)",
)
.option(
"--token <token>",
"Shared token required in hello.auth.token (default: CLAWDIS_GATEWAY_TOKEN env if set)",
@@ -231,6 +235,13 @@ Examples:
defaultRuntime.error("Invalid port");
defaultRuntime.exit(1);
}
const webchatPort = opts.webchatPort
? Number.parseInt(String(opts.webchatPort), 10)
: undefined;
if (webchatPort !== undefined && (Number.isNaN(webchatPort) || webchatPort <= 0)) {
defaultRuntime.error("Invalid webchat port");
defaultRuntime.exit(1);
}
if (opts.force) {
try {
const killed = forceFreePort(port);
@@ -256,7 +267,7 @@ Examples:
process.env.CLAWDIS_GATEWAY_TOKEN = String(opts.token);
}
try {
await startGatewayServer(port);
await startGatewayServer(port, { webchatPort });
} catch (err) {
if (err instanceof GatewayLockError) {
defaultRuntime.error(`Gateway failed to start: ${err.message}`);