#21188: doctor: clean up legacy Linux gateway services
gateway
commands
size: S
Cluster:
Cross-Platform Fixes
## Summary
- add legacy Linux gateway unit names (`clawdbot-gateway`, `moltbot-gateway`) to `LEGACY_GATEWAY_SYSTEMD_SERVICE_NAMES`
- update doctor legacy-service cleanup to remove Linux user legacy services via `uninstallLegacySystemdUnits`
- keep existing macOS legacy cleanup behavior unchanged
- add regression tests for Linux cleanup path and legacy unit-name constants
## Testing
- `env NODE_OPTIONS='' pnpm vitest run src/commands/doctor-gateway-services.test.ts src/daemon/constants.test.ts`
## AI Assistance
- [x] AI-assisted
- Testing level: lightly tested (targeted unit tests above)
- Prompt/session logs: not attached
- Confirmed behavior and code paths were reviewed before submission
Closes #21063
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds legacy Linux gateway unit names (`clawdbot-gateway`, `moltbot-gateway`) to the cleanup constants and implements proper Linux systemd service removal in the doctor command. The implementation correctly handles Linux user-scoped systemd services by calling `uninstallLegacySystemdUnits`, which disables and removes the unit files. The macOS cleanup behavior remains unchanged and continues to use the existing `cleanupLegacyLaunchdService` function.
- Added `clawdbot-gateway` and `moltbot-gateway` to `LEGACY_GATEWAY_SYSTEMD_SERVICE_NAMES` constant
- Updated `maybeScanExtraGatewayServices` to handle Linux legacy services via `uninstallLegacySystemdUnits`
- Maintained backward compatibility with existing macOS cleanup path
- Added comprehensive test coverage for Linux cleanup and constants validation
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The changes are well-scoped, logically sound, and properly tested. The implementation correctly extends existing cleanup infrastructure to handle Linux legacy services without breaking macOS behavior. Error handling is appropriate with try-catch blocks and proper fallback messaging. The test coverage validates the key behavior change.
- No files require special attention
<sub>Last reviewed commit: 8953376</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#11602: fix(config): skip stale legacy config files when openclaw.json exists
by akoscz · 2026-02-08
80.5%
#23666: fix(doctor): openclaw-browser.service falsely flagged as duplicate ...
by yinghaosang · 2026-02-22
78.9%
#15345: fix(daemon): doctor --fix pollutes service PATH with dirs that don'...
by yinghaosang · 2026-02-13
77.3%
#15903: fix(doctor): stricter gateway service detection to prevent false po...
by Shuai-DaiDai · 2026-02-14
76.9%
#10182: fix: skip non-openclaw LaunchAgents in doctor gateway scan
by Yida-Dev · 2026-02-06
76.6%
#5496: Fix: Windows path separators stripped in Gateway scheduled task
by giuliozelante · 2026-01-31
75.6%
#23584: fix(daemon): improve gateway service detection to avoid false posit...
by mohandshamada · 2026-02-22
75.0%
#22108: fix: prevent local DoS by fully clearing systemd services on uninstall
by berkeserce · 2026-02-20
74.8%
#13084: fix(daemon): multi-layer defense against zombie gateway processes
by openperf · 2026-02-10
73.7%
#16016: fix: update systemd unit version on gateway restart
by jbold · 2026-02-14
73.7%