fix(infra): actively kickstart launchd on supervised gateway restart#29078
fix(infra): actively kickstart launchd on supervised gateway restart#29078cathrynlavery wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Greptile SummaryActively triggers Key changes:
How it works: Confidence Score: 5/5
Last reviewed commit: c673e2a |
|
CI note: The |
When an agent triggers a gateway restart in supervised mode, the process exits expecting launchd KeepAlive to respawn it. But ThrottleInterval (default 10s, or 60s on older installs) can delay or prevent restart. Now calls triggerOpenClawRestart() to issue an explicit launchctl kickstart before exiting, ensuring immediate respawn. Falls back to in-process restart if kickstart fails. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c673e2a to
0f85d17
Compare
Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
|
Landed on What we changed on landing:
Validation run before commit:
SHAs:
Thanks @cathrynlavery for the contribution. |
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com> (cherry picked from commit bc28f15)
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com> (cherry picked from commit bc28f15)
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com> (cherry picked from commit bc28f15)
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
…back Co-authored-by: Cathryn Lavery <cathryn@littlemight.com>
Summary
KeepAlive: trueto respawn it. But launchd'sThrottleInterval(60s since fix(gateway): add ThrottleInterval to prevent launchd restart loop #27650) delays the restart, leaving the gateway unresponsive for a full minute on every intentional restart./restartorgateway-tool) should be near-instant. The 60s ThrottleInterval is correct for crash-loop prevention (fix(gateway): add ThrottleInterval to prevent launchd restart loop #27650), but penalizes deliberate restarts unnecessarily.process-respawn.tsnow callstriggerOpenClawRestart()(explicitlaunchctl kickstart -k) on macOS whenOPENCLAW_LAUNCHD_LABELis set, before returningmode: "supervised". Falls back tomode: "failed"on kickstart error sorun-loop.tscan do in-process restart.restart.ts,run-loop.ts, plist generation, or ThrottleInterval value. No new shell commands — reuses existingtriggerOpenClawRestart().Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Agent-triggered restarts on macOS now come back within seconds instead of waiting 60s (ThrottleInterval). No config changes required.
Security Impact (required)
NoNoNoNo— reuses existingtriggerOpenClawRestart()which already callslaunchctl kickstartNoRepro + Verification
Environment
/restartcommandKeepAlive: true,ThrottleInterval: 60Steps
KeepAlive: trueandThrottleInterval: 60/restartorgateway-toolrestartprocess-respawn.tsdetects supervised mode, exits with code 0Expected
launchctl kickstart -kActual (before fix)
Evidence
pnpm test:fast src/infra/process-respawn.test.ts— 9/9 passing (including 2 new kickstart tests + updated stock-plist test).Human Verification (required)
OPENCLAW_LAUNCHD_LABELconfirmed in plistmode: "failed"); non-macOS platforms skip kickstart; missingOPENCLAW_LAUNCHD_LABELskips kickstart/restartend-to-end (ready for testing now — patched build is installed and gateway is running)Compatibility / Migration
YesNo—OPENCLAW_LAUNCHD_LABELis already set by the launchd plistNoFailure Recovery (if this breaks)
OPENCLAW_LAUNCHD_LABELenv to skip the new code path entirelysrc/infra/process-respawn.tsonlymode: "failed"fallback not triggering inrun-loop.ts)Risks and Mitigations
triggerOpenClawRestart()could fail silently on edge-case launchd configsmode: "failed"with detail string;run-loop.tsalready handles this with in-process restart fallback + warning log🤖 Generated with Claude Code