fix: release gateway lock before process.exit in run-loop

process.exit() called from inside an async IIFE bypasses the outer
try/finally block that releases the gateway lock. This leaves a stale
lock file pointing to a zombie PID, preventing the spawned child or
systemctl restart from acquiring the lock. Release the lock explicitly
before calling exit in both the restart-spawned and stop code paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jeffr
2026-02-21 23:14:41 -08:00
committed by Peter Steinberger
parent 6eaf2baa57
commit 01bd83d644
2 changed files with 82 additions and 1 deletions

View File

@@ -90,6 +90,7 @@ export async function runGatewayLoop(params: {
? `spawned pid ${respawn.pid ?? "unknown"}`
: "supervisor restart";
gatewayLog.info(`restart mode: full process restart (${modeLabel})`);
await lock?.release();
cleanupSignals();
params.runtime.exit(0);
} else {
@@ -104,6 +105,7 @@ export async function runGatewayLoop(params: {
restartResolver?.();
}
} else {
await lock?.release();
cleanupSignals();
params.runtime.exit(0);
}