From 127bc620fea71386df0907dcab96a775dd49a04e Mon Sep 17 00:00:00 2001 From: "Ash (Bug Lab)" Date: Sat, 28 Feb 2026 20:50:52 +0800 Subject: [PATCH] fix(update): proactively kill stale gateway PIDs before restart (#28332) --- src/cli/update-cli/update-command.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cli/update-cli/update-command.ts b/src/cli/update-cli/update-command.ts index abc9c0080c7..7a8895b5ffa 100644 --- a/src/cli/update-cli/update-command.ts +++ b/src/cli/update-cli/update-command.ts @@ -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;