#23584: fix(daemon): improve gateway service detection to avoid false positives
gateway
size: XS
Cluster:
Cross-Platform Fixes
## Summary
- Improves `findExtraGatewayServices` to only flag services actually running gateway commands
- Adds `isGatewayCommand` check that examines ExecStart command in service files
- Prevents unrelated services (voice pipelines, custom daemons) from being flagged
## Problem
The `findExtraGatewayServices` function was flagging **any** user-scoped systemd service containing "openclaw", "clawdbot", or "moltbot" as "gateway-like", including unrelated services like voice pipelines on custom ports.
Worse, the cleanup hints suggested disabling/removing the **real gateway**, which would kill the running agent.
## Solution
Added an `isGatewayCommand` check that ensures only services actually running gateway commands (e.g., "openclaw gateway", "clawdbot gateway") are flagged as extra gateway services. The check examines the ExecStart command in the service file and matches against known gateway command patterns:
- `openclaw ... gateway`
- `openclaw-gateway`
- `clawdbot ... gateway`
- `moltbot ... gateway`
This prevents:
- Voice pipelines on custom ports from being flagged
- Any unrelated service mentioning "openclaw" from being flagged
- Cleanup hints suggesting removal of the actual running gateway
Fixes #23550
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds `isGatewayCommand` function to prevent false positives when detecting extra gateway services, addressing an issue where any service mentioning "openclaw" was flagged as a gateway service.
**Key issues found:**
- The `isGatewayCommand` regex logic doesn't correctly parse macOS plist files. It attempts to extract `ExecStart` (Linux-only), then falls back to matching the entire file content, which can cause false positives when service labels contain "gateway" but commands don't.
- Windows task detection doesn't use `isGatewayCommand`, leaving it vulnerable to the same false positives the PR aims to fix.
<h3>Confidence Score: 2/5</h3>
- This PR has logical errors that will cause it to not work correctly on macOS
- The implementation has a critical flaw in the macOS code path where `isGatewayCommand` incorrectly handles plist files by matching against the entire XML content rather than parsing ProgramArguments. This defeats the purpose of the fix and can still produce false positives. Additionally, Windows task detection is inconsistent with the stated goal.
- src/daemon/inspect.ts requires fixes to properly parse macOS plist files and add Windows task filtering
<sub>Last reviewed commit: 688d7f4</sub>
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#15903: fix(doctor): stricter gateway service detection to prevent false po...
by Shuai-DaiDai · 2026-02-14
83.8%
#5496: Fix: Windows path separators stripped in Gateway scheduled task
by giuliozelante · 2026-01-31
80.7%
#23666: fix(doctor): openclaw-browser.service falsely flagged as duplicate ...
by yinghaosang · 2026-02-22
80.6%
#10182: fix: skip non-openclaw LaunchAgents in doctor gateway scan
by Yida-Dev · 2026-02-06
79.8%
#11147: fix(daemon): stop gateway by port when no daemon service is active
by jasonthewhale · 2026-02-07
79.6%
#13084: fix(daemon): multi-layer defense against zombie gateway processes
by openperf · 2026-02-10
78.8%
#16845: fix(daemon): gateway auto-restart on SIGTERM + agent restart guidel...
by kiminbean · 2026-02-15
77.6%
#8260: fix(macOS): gateway readiness detection + reversible Configure later
by xksteven · 2026-02-03
77.5%
#22304: Gateway: fix launchd start after stop
by apethree · 2026-02-21
77.4%
#17835: Fix misleading gateway stop hints for standalone listeners
by ConnorCallison · 2026-02-16
77.3%