Files
windmill/dev-dashboard/backend/src/env.ts
T
centdix a4b440a20d feat: add socat port forwarding for sandbox containers
When a worktree runs inside a Docker sandbox, its ports are only
reachable via the container's bridge IP. socat forwards host ports to
the container so the browser (over SSH) can reach them.

- New socat.ts module manages forwarding lifecycle (start/stop/reconcile)
- Polls for container after creation (non-blocking, up to 30s)
- Kills orphaned socat on startup before re-establishing forwards
- Cleans up on worktree removal and SIGINT/SIGTERM
- Extract readEnvLocal to env.ts to break circular import
- Change isPortListening to HTTP fetch (avoids socat false positives)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 18:49:59 +00:00

16 lines
527 B
TypeScript

/** Read key=value pairs from a worktree's .env.local file. */
export function readEnvLocal(wtDir: string): Record<string, string> {
try {
const content = Bun.spawnSync(["cat", `${wtDir}/.env.local`], { stdout: "pipe" });
const text = new TextDecoder().decode(content.stdout).trim();
const env: Record<string, string> = {};
for (const line of text.split("\n")) {
const match = line.match(/^(\w+)=(.*)$/);
if (match) env[match[1]] = match[2];
}
return env;
} catch {
return {};
}
}