Fix some issues with local dev
Build and Push Spoon Images / quality (push) Successful in 1m32s
Build and Push Spoon Images / build-images (push) Successful in 6m33s

This commit is contained in:
Gabriel Brown
2026-06-24 22:40:26 -04:00
parent 573246ce98
commit 3f1fee4e44
7 changed files with 86 additions and 40 deletions
+3
View File
@@ -48,6 +48,9 @@ export const env = {
terminalIdleMs: intEnv('SPOON_AGENT_TERMINAL_IDLE_MS', 1_800_000),
// How long a per-user box container survives with no active jobs/terminals.
boxIdleMs: intEnv('SPOON_AGENT_BOX_IDLE_MS', 1_800_000),
// Dev-only: exit if the parent dev runner dies, so the worker never orphans
// and holds port 3921 across restarts. Set by scripts/dev-agent-worker.
devWatchdog: process.env.SPOON_AGENT_DEV_WATCHDOG === '1',
workdir: process.env.SPOON_AGENT_WORKDIR?.trim() ?? '.local/agent-work',
hostWorkdir: process.env.SPOON_AGENT_HOST_WORKDIR?.trim(),
network: process.env.SPOON_AGENT_NETWORK?.trim(),
+24
View File
@@ -1,5 +1,29 @@
import { env } from './env';
import { startWorkerServer } from './server';
import { startWorker } from './worker';
// Dev-only watchdog: the dev runner chain (turbo → with-env → dotenv → bash)
// doesn't always forward the stop signal to this leaf process, so on restart the
// worker can orphan and keep holding port 3921. Exit when our original parent
// goes away (we get reparented) or on a stop signal, so restarts stay clean.
// Never enabled in prod (gated on SPOON_AGENT_DEV_WATCHDOG).
if (env.devWatchdog) {
// Bun caches `process.ppid`, so poll whether the original parent still exists
// (signal 0 throws once it's gone) rather than comparing ppid.
const parentPid = process.ppid;
const watcher = setInterval(() => {
try {
process.kill(parentPid, 0);
} catch {
console.log('Dev parent exited; shutting down worker.');
process.exit(0);
}
}, 1000);
watcher.unref();
for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP'] as const) {
process.on(signal, () => process.exit(0));
}
}
startWorkerServer();
await startWorker();