#7155: fix(gateway): use kill SIGTERM instead of bootout for stop
gateway
Cluster:
Gateway Restart Improvements
## Problem
`openclaw gateway stop` uses `launchctl bootout` which completely unloads the LaunchAgent from launchd. This means after stopping, users must run:
```bash
openclaw gateway install && openclaw gateway start
```
Instead of just:
```bash
openclaw gateway start
```
## Solution
Replace `launchctl bootout` with `launchctl kill SIGTERM` in `stopLaunchAgent()`. This:
- Stops the process gracefully (SIGTERM)
- Keeps the LaunchAgent loaded in launchd
- Allows `start` to work immediately via `kickstart`
## Testing
1. `openclaw gateway stop` → service stops but stays loaded
2. `openclaw gateway start` → service restarts without install
## Notes
- `bootout` is still used in `uninstallLaunchAgent()` where full removal is intended
- `kill` only affects running services; error handling for not-loaded cases is preserved
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR changes the macOS launchd stop behavior for the gateway LaunchAgent: `stopLaunchAgent()` now uses `launchctl kill SIGTERM` instead of `launchctl bootout`, so the agent remains loaded in launchd and can be restarted immediately via `kickstart` without requiring a reinstall.
The change is localized to `src/daemon/launchd.ts` and preserves the previous pattern of ignoring certain non-zero `launchctl` results via `isLaunchctlNotLoaded`, while continuing to use `bootout`/`unload` for full removal in uninstall flows.
<h3>Confidence Score: 4/5</h3>
- This PR is reasonably safe to merge, with a small behavioral edge case around stop-idempotency when the service isn’t running.
- The change is small and targeted (one command swap plus messaging), but `launchctl kill` has different non-zero exit behaviors than `bootout`, and the current “not loaded” matcher may not treat common “already stopped” cases as non-fatal, which could regress `openclaw gateway stop` for some macOS versions/states.
- src/daemon/launchd.ts (stopLaunchAgent error classification)
<!-- greptile_other_comments_section -->
<sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#16845: fix(daemon): gateway auto-restart on SIGTERM + agent restart guidel...
by kiminbean · 2026-02-15
84.9%
#11327: fix(launchd): reload plist from disk on restartLaunchAgent
by caiop91 · 2026-02-07
82.4%
#11147: fix(daemon): stop gateway by port when no daemon service is active
by jasonthewhale · 2026-02-07
80.7%
#18236: macOS daemon: bootstrap LaunchAgent on gateway start after stop
by agisilaos · 2026-02-16
80.6%
#22304: Gateway: fix launchd start after stop
by apethree · 2026-02-21
79.7%
#9460: fix(gateway): clean up lock file on service stop
by zenchantlive · 2026-02-05
78.3%
#13084: fix(daemon): multi-layer defense against zombie gateway processes
by openperf · 2026-02-10
75.8%
#8260: fix(macOS): gateway readiness detection + reversible Configure later
by xksteven · 2026-02-03
75.4%
#15619: fix: clean up orphan LaunchAgent plist on bootstrap failure
by superlowburn · 2026-02-13
74.8%
#17835: Fix misleading gateway stop hints for standalone listeners
by ConnorCallison · 2026-02-16
74.8%