fix: release gateway lock on restart failure + reply to Codex reviews

- Release gateway lock when in-process restart fails, so daemon
  restart/stop can still manage the process (Codex P2)
- P1 (env mismatch) already addressed: best-effort by design, documented
  in JSDoc
This commit is contained in:
merlin
2026-03-09 12:36:05 +08:00
committed by Peter Steinberger
parent f184e7811c
commit f84adcbe88

View File

@@ -206,6 +206,11 @@ export async function runGatewayLoop(params: {
throw err;
}
server = null;
// Release the gateway lock so that `daemon restart/stop` (which
// discovers PIDs via the gateway port) can still manage the process.
// Without this, the process holds the lock but is not listening,
// forcing manual cleanup. (#35862)
await releaseLockIfHeld();
const errMsg = err instanceof Error ? err.message : String(err);
const errStack = err instanceof Error && err.stack ? `\n${err.stack}` : "";
gatewayLog.error(