fix(update): proactively kill stale gateway PIDs before restart (#28332)

This commit is contained in:
Ash (Bug Lab) 2026-02-28 20:50:52 +08:00
parent 8a05c05596
commit 127bc620fe

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,
@ -589,6 +590,10 @@ async function maybeRestartService(params: {
}
}
}
// Proactively kill any stale gateway processes (e.g. bare-process nohup gateways)
// holding the port before we attempt the restart. Without this, the new process
// fails to bind the port and openclaw update leaves two conflicting gateway PIDs.
cleanStaleGatewayProcessesSync();
if (params.restartScriptPath) {
await runRestartScript(params.restartScriptPath);
restartInitiated = true;