diff --git a/sidecar/config.ts b/sidecar/config.ts index 72012cd..5745560 100644 --- a/sidecar/config.ts +++ b/sidecar/config.ts @@ -22,7 +22,20 @@ function num(key: string, fallback: number, min: number): number { return value; } -export const PORT = num("AV_CLUB_PORT", 3020, 1); +/** + * The port to listen on. **0 means "any free one", and that is the default.** + * + * A plugin sidecar does not choose a number. It binds whatever is free and REPORTS it to the platform, + * which is how every other sidecar here works and why none of them can collide. av-club asserted 3020 + * because it began life as a standalone service, and on 2026-08-28 that assumption cost a deploy: a + * stale copy of the pre-plugin code was still holding 3020 on fofos, so the plugin's sidecar died on + * EADDRINUSE in a restart loop. + * + * `AV_CLUB_PORT` still works and still pins the port. That is for running this outside Officer — the + * standalone mode fofos/platform was written against — where something on the other side has to know + * where to find it. Inside Officer nothing should set it. + */ +export const PORT = num("AV_CLUB_PORT", 0, 0); /** * Where assets live. Outside the repo by default, and deliberately not under any directory a deploy diff --git a/sidecar/index.ts b/sidecar/index.ts index 43172e8..8ace688 100644 --- a/sidecar/index.ts +++ b/sidecar/index.ts @@ -217,8 +217,8 @@ const connection = createSidecarConnector({ reply({ type: "error", id: (_cmd as { id: string }).id, error: "av-club takes no commands; use its HTTP API" }); }, onConnected() { - connection.send({ type: "av-club:server", port: PORT }); - console.log(`[av-club] reported port ${PORT} to the API`); + connection.send({ type: "av-club:server", port: server.port! }); + console.log(`[av-club] reported port ${server.port} to the API`); }, });