-
-
Notifications
You must be signed in to change notification settings - Fork 52.7k
Description
Summary
When both LaunchAgent (KeepAlive: true) and the App's GatewayLaunchAgentManager manage the gateway lifecycle, they conflict — causing a restart loop, duplicate processes, and 100% CPU.
Steps to reproduce
- Install OpenClaw and start the App (macOS, Apple Silicon)
-
- App runs GatewayLaunchAgentManager → installs LaunchAgent with KeepAlive: true → kickstart gateway
-
- Close and reopen the App
-
- App runs ensure gateway → kickstart again, even though LaunchAgent already has gateway running
-
- Observe: two openclaw-gateway processes running simultaneously, CPU at 100%
Additionally, App sends SIGUSR1 to gateway every 8-11 minutes with no config change (see [Bug]: OpenClaw.app (desktop) triggers periodic SIGUSR1 gateway restarts #10600), which combined with KeepAlive: true causes continuous restart loop.
- Observe: two openclaw-gateway processes running simultaneously, CPU at 100%
Expected behavior
App opens → detects if gateway is running → if already running via LaunchAgent, does NOT kickstart again. Only one gateway process runs at a time. LaunchAgent KeepAlive should use SuccessfulExit: true so intentional stops are respected.
Actual behavior
Two openclaw-gateway processes run simultaneously, consuming ~100% CPU. Gateway repeatedly restarts (PID changes every few seconds). App UI shows gateway going up/down continuously. CPU only returns to normal after closing the App.
Log signature:
[gateway] signal SIGUSR1 received
[gateway] received SIGUSR1; restarting
[ws] unauthorized role: node (repeated every second)
Root cause: KeepAlive: true in LaunchAgent causes launchd to restart gateway whenever App's kickstart stops it. Combined with App's periodic SIGUSR1 signals (#10600), creates a continuous restart loop.
Suggested fix:
- Change plist KeepAlive from
trueto{ SuccessfulExit: true }— only restart on crash, not on intentional stop -
- Add
ThrottleInterval: 5to prevent exponential backoff on crash loops (Gateway crashes with EPIPE on LaunchAgent restart, causes exponential throttle #4632)
- Add
-
- App's GatewayLaunchAgentManager should check if gateway is already running before kickstart
Reference: colima/issues/1490 (same KeepAlive conflict pattern)
- App's GatewayLaunchAgentManager should check if gateway is already running before kickstart
OpenClaw version
v0.9.14 (gateway)
Operating system
macOS 15 (Sequoia), Apple Silicon (M4 Max)
Install method
npm global
Logs, screenshots, and evidence
Impact and severity
No response
Additional information
Related issues: #10600 (App sends periodic SIGUSR1), #4632 (EPIPE crash + exponential backoff, ThrottleInterval suggestion)