fix: detect macOS gateway service processes reliably - #11293
Conversation
|
I reproduced this locally on a live macOS launchd-managed Hermes install and wanted to add a +1 with a concrete repro. Observed behavior:
I independently implemented the same fix and compared the overlapping open PRs. This PR looks like the strongest version of the fix to me: narrow scope, correct root-cause analysis, and focused regression coverage. I opened a duplicate while investigating ( |
|
Thanks for the focused macOS investigation and reproduction details. Current main still has the macOS process-scan gap: after the Problems
Suggested changes
This is an automated hermes-sweeper review. |
macOS ps rejects the BSD `e` flag in `ps -A eww`, so whenever /proc is unavailable (always true on macOS) _scan_gateway_pids() silently found nothing and gateway/cron status reported a live gateway as down. - select `ps -Aww -o pid=,command=` on macOS; keep `ps -A eww` on Linux - add regression tests for both argv selections with /proc forced unavailable The launchctl plist-parsing half of the original PR landed separately on main (_parse_launchd_pid_from_list_output), so this branch now carries only the process-scan fix, per review feedback. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
85b4574 to
edc695d
Compare
|
@teknium1 Thanks for the review — rescoped as suggested. Since the launchctl plist parsing already landed on main via _parse_launchd_pid_from_list_output(), I've rebased onto main and dropped that half entirely. The branch now carries only the macOS ps argv selection, applied to _scan_gateway_pids()'s fallback path: ps -Aww -o pid=,command= on macOS, unchanged ps -A eww elsewhere. The old find_gateway_pids()-era tests are replaced with a TestScanGatewayPidsPsSelection class that forces /proc unavailable and asserts the argv for both platforms, preserving the existing Linux assertion. Also confirmed on a live macOS box that ps -A eww -o pid=,command= fails with illegal argument: eww while the new invocation succeeds. |
Summary
Fixes false-negative gateway/cron status detection on macOS by making the manual process-table scan use a macOS-valid
psinvocation.Problem
On macOS,
_scan_gateway_pids()falls back topswhen/procis unavailable — which is always the case on macOS. The fallback invocationps -A eww -o pid=,command=is rejected by macOSps:so the scan silently found nothing, and commands like
hermes cron statusreported the gateway as down even while a launchd-managed gateway was alive.What changed
_scan_gateway_pids()now selectsps -Aww -o pid=,command=on macOS and keeps the existingps -A eww -o pid=,command=invocation everywhere else, so Linux behavior is untouched.TestScanGatewayPidsPsSelection) exercise the fallback with/procforced unavailable: one asserts the macOS argv, the other preserves the existing Linux argv assertion.Notes
On macOS,
ps -Awwcannot surface env vars the way Linuxps ewwdoes, so gateways started with onlyHERMES_HOME=<path>in the environment (no--profileflag) won't be attributable to a named profile via_matches_current_profile. This is called out inline in the code; this PR does not attempt to change profile attribution behavior.Tests
tests/hermes_cli/test_gateway_service.py::TestScanGatewayPidsPsSelection— 2 passedps -A eww -o pid=,command=exits 1 (illegal argument: eww),ps -Aww -o pid=,command=exits 0.