Skip to content

fix: bind shard manager to 0.0.0.0 for inter-container connectivity - #1

Open
railway-app[bot] wants to merge 10 commits into
prod-pinfrom
railway/code-change-f1JfcA
Open

fix: bind shard manager to 0.0.0.0 for inter-container connectivity#1
railway-app[bot] wants to merge 10 commits into
prod-pinfrom
railway/code-change-f1JfcA

Conversation

@railway-app

@railway-app railway-app Bot commented May 6, 2026

Copy link
Copy Markdown

Problem

The Cap Shard Manager was binding exclusively to 127.0.0.1:8080 (loopback) because NodeClusterShardManagerSocket.layer() in apps/web-cluster/src/shard-manager.ts had no host configured, causing it to default to localhost. This made the shard manager unreachable from the Cap Workflow Runner container via cap-shard-manager.railway.internal:8080.

Solution

Added a host field to the NodeClusterShardManagerSocket.layer() options, read from the SHARD_MANAGER_HOST environment variable with a default of "0.0.0.0". This causes the shard manager to bind to all interfaces by default, making it reachable from other containers over the internal Railway network. The bind address can still be overridden to 127.0.0.1 via the env var if loopback-only is ever needed.

Changes

  • Modified apps/web-cluster/src/shard-manager.ts

Generated by Railway

Mudit-Lal and others added 10 commits May 6, 2026 11:10
Railway's Buildkit rejects `# syntax=docker.io/docker/dockerfile:1`. Default frontend works fine for this multi-stage build.
Railway sub-directory deploys (rootDirectory=apps/media-server) need the
standalone Dockerfile whose COPY paths are relative to apps/media-server,
not the root Dockerfile that expects repo-root paths.
Railway's Railpack builder rejects `--mount=type=cache,id=pnpm,...` without
a cacheKey prefix on the id. Dropping the cache mount; build is slower but
correct.
Same Railway Railpack constraint as apps/web/Dockerfile — id=pnpm without
cacheKey prefix is rejected.
…full command

Railway's startCommand exec's the literal string and does NOT append to a
Docker ENTRYPOINT. With `ENTRYPOINT ["deno", "run", "--allow-all"]` Railway
tries to run the startCommand as a file path, getting "permission denied".

Removing ENTRYPOINT means startCommand becomes the CMD via shell, so
`deno run --allow-all src/runner/index.ts` works as expected.
Railway's startCommand fights with multi-word commands (treats whole string
as executable path). Switching strategy: hardcode CMD in Dockerfile to invoke
deno + ${CLUSTER_ENTRY}. Each service sets CLUSTER_ENTRY env var (default =
runner) so no startCommand override needed.
…er Dockerfile

Railway's startCommand override mechanism keeps fighting multi-word commands
on this Deno-based image. Hardcoding the CMD per Dockerfile sidesteps the
fight entirely. This Dockerfile is now Runner-only; ShardManager gets its
own Dockerfile.shard-manager.
Variant of apps/web-cluster/Dockerfile whose only difference is the final
CMD points at src/shard-manager.ts instead of src/runner/index.ts.
post-deploy.ts merges publishConfig into the deployed package.json. Without
publishConfig.exports, the deployed package keeps `exports: "./src/index.ts"`
and Deno tries to load TS source from node_modules, hitting
ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING and crashing the runner.

Mirroring the pattern @cap/database uses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant