fix(gateway): fix macOS gateway PID detection in find_gateway_pids#10636
Open
IISweetHeartII wants to merge 1 commit into
Open
fix(gateway): fix macOS gateway PID detection in find_gateway_pids#10636IISweetHeartII wants to merge 1 commit into
IISweetHeartII wants to merge 1 commit into
Conversation
Two issues prevent `find_gateway_pids()` from detecting the running
gateway process on macOS, causing `hermes cron status` to falsely
report "Gateway is not running" even when the process is alive and
healthy.
**1. `launchctl list <label>` output format mismatch**
Modern macOS (12+) returns a property-list dictionary format:
"PID" = 12345;
The existing parser expected the legacy tabular format:
PID Status Label
Added regex-based extraction for the modern dict format with a
fallback to the legacy tabular parser.
Refs: NousResearch#4820
**2. `ps` flag argument splitting**
`subprocess.run(["ps", "-A", "eww", ...])` passes `eww` as a
separate argument, which BSD `ps` interprets as a process name
filter rather than flags. This returns ~5 results instead of the
full process list (~400+), causing pattern matching to miss the
gateway process.
Fixed by combining flags: `["ps", "-Aeww", ...]`
Refs: NousResearch#9069, NousResearch#9100
Tested on macOS 15.4 (Sequoia) with launchd-managed gateway.
Before: `hermes cron status` → "Gateway is not running"
After: `hermes cron status` → "Gateway is running — PID: <pid>"
19 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
find_gateway_pids()fails to detect running gateway processes on macOS, causinghermes cron statusto report "Gateway is not running" even when the gateway is alive and healthy (/healthreturns OK).Two root causes:
1.
launchctl list <label>output format mismatchModern macOS (12+) returns a property-list dictionary:
The parser expects legacy tabular format (
PID\tStatus\tLabel) and never extracts the PID.Fix: Regex extraction (
"PID"\s*=\s*(\d+)) for the modern dict format, with fallback to the legacy tabular parser.2.
psflag argument splitting (#9069, #9100)When
ewwis a separate argument, BSDpsinterprets it as a process name filter instead of flags, returning only processes matching "eww" as a keyword.Test plan
Tested on macOS 15.4 (Sequoia) with launchd-managed gateway:
hermes cron statuscorrectly shows "Gateway is running — PID: <pid>"hermes cron run <id>fires and completes successfullyhermes cron tickexecutes due jobshermes update(restart detection still works)Related issues
ps ewwoutput format #9069 — FreeBSDps ewwgateway detection failsps ewwtops ww(this PR provides an alternative fix)