Bug Description
On FreeBSD, hermes cron list and hermes cron status incorrectly report "Gateway is not running" even when the gateway is actively running and processing messages.
Steps to Reproduce
- Run
hermes gateway run
- Send message to create cron job from channel
- Run
hermes cron list, you will get schedule jobs list and Gateway is not running - jobs won't fire automatically.
Expected Behavior
No warning and error, and cron jobs are running normally.
Actual Behavior
Cron job not running and get warning message in hermes cron list.
Affected Component
Gateway (Telegram/Discord/Slack/WhatsApp), CLI (interactive chat)
Messaging Platform (if gateway-related)
No response
Operating System
FreeBSD 15.0-RELEASE-p5
Python Version
3.11.15
Hermes Version
0.8.0
Relevant Logs / Traceback
Root Cause Analysis (optional)
The function find_gateway_pids() in hermes_cli/gateway.py uses this ps command to list processes:
["ps", "eww", "-ax", "-o", "pid=,command="]
On FreeBSD, the eww flags (environment variables + unlimited width) cause the command column to be prefixed with all environment variables, in this format:
PID COMMAND
87727 _=/home/pader/.local/bin/hermes PWD=/home/pader/.hermes RUSTUP_UPDATE_ROOT=... PATH=... /home/pader/.hermes/hermes-agent/venv/bin/python3 /home/pader/.local/bin/hermes gateway run -v (python3.11)
The parsing logic then uses split(None, 1) to split the line, expecting the PID to be the first token and the command to be the second. However, because the entire environment block comes before the actual command, the second token is _=/home/... (an env var assignment), not the executable path.
As a result, none of the gateway detection patterns match:
patterns = [
"hermes_cli.main gateway",
"hermes gateway",
"gateway/run.py",
# etc.
]
Evidence
ps eww output (broken):
87727 _=/home/pader/.local/bin/hermes PWD=/home/pader/.hermes ... /home/pader/.hermes/hermes-agent/venv/bin/python3 /home/pader/.local/bin/hermes gateway run -v (python3.11)
ps -aww output (correct):
87727 /home/pader/.hermes/hermes-agent/venv/bin/python3 /home/pader/.local/bin/hermes gateway run -v (python3.11)
The ps -aww format does not include environment variables and correctly shows the executable path, allowing pattern matching to work.
Proposed Fix (optional)
In hermes_cli/gateway.py, line ~224, change:
["ps", "eww", "-ax", "-o", "pid=,command="]
to:
["ps", "ww", "-ax", "-o", "pid=,command="]
Removing the e flag avoids including environment variables in the output, which fixes the parsing issue on FreeBSD while maintaining the unlimited width output needed for long command lines.
Are you willing to submit a PR for this?
Bug Description
On FreeBSD,
hermes cron listandhermes cron statusincorrectly report "Gateway is not running" even when the gateway is actively running and processing messages.Steps to Reproduce
hermes gateway runhermes cron list, you will get schedule jobs list andGateway is not running - jobs won't fire automatically.Expected Behavior
No warning and error, and cron jobs are running normally.
Actual Behavior
Cron job not running and get warning message in
hermes cron list.Affected Component
Gateway (Telegram/Discord/Slack/WhatsApp), CLI (interactive chat)
Messaging Platform (if gateway-related)
No response
Operating System
FreeBSD 15.0-RELEASE-p5
Python Version
3.11.15
Hermes Version
0.8.0
Relevant Logs / Traceback
Root Cause Analysis (optional)
The function
find_gateway_pids()inhermes_cli/gateway.pyuses thispscommand to list processes:On FreeBSD, the eww flags (environment variables + unlimited width) cause the command column to be prefixed with all environment variables, in this format:
The parsing logic then uses split(None, 1) to split the line, expecting the PID to be the first token and the command to be the second. However, because the entire environment block comes before the actual command, the second token is _=/home/... (an env var assignment), not the executable path.
As a result, none of the gateway detection patterns match:
Evidence
ps eww output (broken):
ps -aww output (correct):
The ps -aww format does not include environment variables and correctly shows the executable path, allowing pattern matching to work.
Proposed Fix (optional)
In hermes_cli/gateway.py, line ~224, change:
to:
Removing the e flag avoids including environment variables in the output, which fixes the parsing issue on FreeBSD while maintaining the unlimited width output needed for long command lines.
Are you willing to submit a PR for this?