From c183c68f123013872359f92f6a147d3248e49170 Mon Sep 17 00:00:00 2001 From: Wylabb <77673282+Wylabb@users.noreply.github.com> Date: Tue, 7 Apr 2026 23:25:40 +0200 Subject: [PATCH] Parse port from CLAW_WORKER_BIND_ADDR The gateway passes CLAW_WORKER_BIND_ADDR as "host:port" (e.g. "0.0.0.0:8080"). Parse both from it instead of using a separate CLAW_WORKER_PORT env var. Default to port 8080 to match the gateway's DEFAULT_GATEWAY_WORKER_BIND_PORT. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/worker/Dockerfile | 7 +++---- src/worker/main.ts | 11 +++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/worker/Dockerfile b/src/worker/Dockerfile index 1a9e736..bf10acc 100644 --- a/src/worker/Dockerfile +++ b/src/worker/Dockerfile @@ -34,17 +34,16 @@ COPY src/worker/ src/worker/ RUN mkdir -p /state/claude-home /state/claw /workspace # Default env -ENV CLAW_WORKER_BIND_ADDR=0.0.0.0 -ENV CLAW_WORKER_PORT=8780 +ENV CLAW_WORKER_BIND_ADDR=0.0.0.0:8080 ENV CLAW_WORKER_STATE_ROOT=/state ENV CLAW_WORKER_DEFAULT_CWD=/workspace ENV CLAW_WORKER_MODEL=claude-sonnet-4-6 ENV CLAW_WORKER_PERMISSION_MODE=default ENV CLAUDE_CONFIG_DIR=/state/claude-home -EXPOSE 8780 +EXPOSE 8080 HEALTHCHECK --interval=10s --timeout=3s --start-period=5s \ - CMD curl -f http://localhost:8780/healthz || exit 1 + CMD curl -f http://localhost:8080/healthz || exit 1 CMD ["bun", "run", "src/worker/main.ts"] diff --git a/src/worker/main.ts b/src/worker/main.ts index cd3554e..fa1ecfe 100644 --- a/src/worker/main.ts +++ b/src/worker/main.ts @@ -18,8 +18,15 @@ import { startWorkerServer } from './server.js' -const bindAddr = process.env.CLAW_WORKER_BIND_ADDR ?? '127.0.0.1' -const port = parseInt(process.env.CLAW_WORKER_PORT ?? '8780', 10) +// The gateway passes CLAW_WORKER_BIND_ADDR as "host:port" (e.g. "0.0.0.0:8080"). +// Parse both address and port from it, with CLAW_WORKER_PORT as override. +const rawBindAddr = process.env.CLAW_WORKER_BIND_ADDR ?? '0.0.0.0:8080' +const colonIdx = rawBindAddr.lastIndexOf(':') +const bindAddr = colonIdx > 0 ? rawBindAddr.slice(0, colonIdx) : rawBindAddr +const port = parseInt( + process.env.CLAW_WORKER_PORT ?? (colonIdx > 0 ? rawBindAddr.slice(colonIdx + 1) : '8080'), + 10, +) const authToken = process.env.CLAW_WORKER_AUTH_TOKEN const profileId = process.env.CLAW_WORKER_PROFILE_ID ?? 'default' const stateRoot = process.env.CLAW_WORKER_STATE_ROOT ?? '/tmp/claw-worker-state'