Merge f7760757fde0afc80a73acd54deb61589dbf7714 into 8a05c05596ca9ba0735dafd8e359885de4c2c969

This commit is contained in:
BlueBirdBack ✨ 2026-03-21 06:00:22 +00:00 committed by GitHub
commit 6ae3dffff8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,6 +12,7 @@ import {
} from "../../config/config.js";
import { formatConfigIssueLines } from "../../config/issue-format.js";
import { resolveGatewayService } from "../../daemon/service.js";
import { cleanStaleGatewayProcessesSync } from "../../infra/restart-stale-pids.js";
import {
channelToNpmTag,
DEFAULT_GIT_CHANNEL,
@ -590,9 +591,19 @@ async function maybeRestartService(params: {
}
}
if (params.restartScriptPath) {
// A managed service restart script is available: kill stale bare-process
// gateway PIDs first so the service can bind the port on the way up.
// We only do this when we have a guaranteed restart path — killing the
// live gateway without a viable replacement would leave it down.
cleanStaleGatewayProcessesSync();
await runRestartScript(params.restartScriptPath);
restartInitiated = true;
} else {
// No restart script — fall back to daemon restart. Skip the proactive
// PID cleanup here: if the daemon is not loaded runDaemonRestart returns
// false and we would kill the live gateway with no replacement. The
// post-restart health check (waitForGatewayHealthyRestart) already
// handles stale PID cleanup once the new gateway is confirmed healthy.
restarted = await runDaemonRestart();
}