Skip to content

Cherry-pick 63c6080: fix: clean stale gateway PIDs before restart#1163

Merged
alexey-pelykh merged 1 commit intomainfrom
cherry-pick/63c6080-clean-stale-pids
Mar 13, 2026
Merged

Cherry-pick 63c6080: fix: clean stale gateway PIDs before restart#1163
alexey-pelykh merged 1 commit intomainfrom
cherry-pick/63c6080-clean-stale-pids

Conversation

@alexey-pelykh
Copy link
Copy Markdown

Cherry-pick from upstream

Upstream commit: 63c6080
Author: SidQin-cyber
Tier: AUTO-PICK

fix: clean stale gateway PIDs before triggerOpenClawRestart calls launchctl/systemctl

Resolved merge conflict: upstream added new functions (findGatewayPidsOnPortSync, terminateStaleProcessesSync, cleanStaleGatewayProcessesSync) before the function declaration that the fork had renamed. Kept fork's triggerRemoteClawRestart name, rebranded openclawremoteclaw in process name matching.

Depends on #1162

…nchctl/systemctl

When the /restart command runs inside an embedded agent process (no
SIGUSR1 listener), it falls through to triggerOpenClawRestart() which
calls launchctl kickstart -k directly — bypassing the pre-restart port
cleanup added in openclaw#27013. If the gateway was started via TUI/CLI, the
orphaned process still holds the port and the new launchd instance
crash-loops.

Add synchronous stale-PID detection (lsof) and termination
(SIGTERM→SIGKILL) inside triggerOpenClawRestart() itself, so every
caller — including the embedded agent /restart path — gets port cleanup
before the service manager restart command fires.

Closes openclaw#26736

Made-with: Cursor
(cherry picked from commit 63c6080)
@alexey-pelykh alexey-pelykh merged commit 4ef536a into main Mar 13, 2026
7 checks passed
@alexey-pelykh alexey-pelykh deleted the cherry-pick/63c6080-clean-stale-pids branch March 13, 2026 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants