Repository navigation
Description
Bug Description
On macOS with Docker Desktop using virtiofs, get_running_pid() in gateway/status.py returns None even when the gateway process is running.
Root cause: is_gateway_runtime_lock_active() opens the lock file by path to check if the advisory lock is held. On virtiofs (macOS Docker Desktop default since 4.x), the lock file's directory entry can be unlinked while the gateway process still holds the lock on the open FD. A subsequent call to is_gateway_runtime_lock_active() tries to open the path — finds nothing — and returns False. The current code treats this as definitive proof the gateway is down:
lock_active = is_gateway_runtime_lock_active(resolved_lock_path)
if not lock_active: # <-- wrong on virtiofs
_cleanup_invalid_pid_path(resolved_pid_path, cleanup_stale=cleanup_stale)
return NoneThis early exit skips the PID file check entirely. lock_active is still computed (it feeds _read_gateway_lock_record() which checks the FD-held lock) — only the early return None needs to go.
Steps to Reproduce
- macOS host, Docker Desktop with virtiofs (default since Docker Desktop 4.6+)
- Start Hermes gateway
- Wait for virtiofs to unlink the lock file directory entry (or manually:
rm .hermes/gateway.lockfrom the host while gateway is running) - Call
gateway.get_running_pid()— returnsNone - Click "Restart Gateway" in the dashboard — a second instance spawns alongside the running one
Expected Behavior
get_running_pid() should check the PID file regardless of lock state and return the running PID if the process is alive. Clicking "Restart Gateway" should replace the running gateway, not spawn a duplicate.
Actual Behavior
get_running_pid() returns None. The dashboard shows STOPPED even though the gateway is live (handling requests, Telegram connected). Clicking "Restart Gateway" spawns a second gateway instance alongside the original.
Observed incident: macOS Docker Desktop (virtiofs), gateway.lock FD visible in /proc/<pid>/fd/ as (deleted) while gateway was live.
Affected Component
Gateway (Telegram/Discord/Slack/WhatsApp)
Messaging Platform (if gateway-related)
No response
Debug Report
version: 0.16.0 (2026.6.5) [a118b94a]
os: Linux 6.12.76-linuxkit aarch64
python: 3.13.5
profile: local-admin
gateway: running (s6 (container supervisor), pid 2050)
platforms: telegram
cron_jobs: 8 active / 13 total
skills: 48
config_overrides:
agent.max_turns: 150
agent.gateway_timeout: 3600
Note: gateway deployment in Docker container; hermes debug share --local used instead of upload.Operating System
macOS host + Docker Desktop (virtiofs); container: Linux 6.12.76-linuxkit aarch64
Python Version
3.13.5
Hermes Version
0.16.0 (2026.6.5) [a118b94]
Additional Logs / Traceback (optional)
From host: `ls -la .hermes/` shows gateway.lock present
From container: `/proc/<gateway_pid>/fd/` shows gateway.lock as "(deleted)"
Gateway was live — Telegram messages received and responded to normally throughoutRoot Cause Analysis (optional)
is_gateway_runtime_lock_active() in gateway/status.py opens the lock file by path. On macOS Docker Desktop with virtiofs, the lock file's directory entry can be removed while the gateway process still holds the advisory lock on the open file descriptor.
- Before virtiofs unlinking:
is_gateway_runtime_lock_active()returnsTrue→ code proceeds normally to PID check - After virtiofs unlinks the directory entry:
is_gateway_runtime_lock_active()opens by path, finds nothing, returnsFalse→ code hits earlyreturn None, skips PID file entirely
Fix: remove the early return None. lock_active is still computed (it feeds into _read_gateway_lock_record()) — only the short-circuit return is removed. On Linux hosts where virtiofs is not involved, removing the early return is a no-op: the PID file check safely handles genuinely-not-running cases.
File: gateway/status.py, function get_running_pid(), around line 935.
Proposed Fix (optional)
--- a/gateway/status.py 2026-05-29 03:12:25
+++ b/gateway/status.py 2026-06-12 20:52:35
@@ -935,10 +935,13 @@
resolved_pid_path = pid_path or _get_pid_path()
resolved_lock_path = _get_gateway_lock_path(resolved_pid_path)
lock_active = is_gateway_runtime_lock_active(resolved_lock_path)
- if not lock_active:
- _cleanup_invalid_pid_path(resolved_pid_path, cleanup_stale=cleanup_stale)
- return None
-
+
+ # Always check the PID file regardless of lock state. On macOS with
+ # virtiofs, the lock file's directory entry can be unlinked while the
+ # gateway process still holds the advisory lock on the open FD, causing
+ # is_gateway_runtime_lock_active() to return False on a fresh open even
+ # though the gateway is alive. Skipping the PID check in that case makes
+ # "Restart Gateway" spawn a second instance instead of replacing the first.
primary_record = _read_pid_record(resolved_pid_path)
fallback_record = _read_gateway_lock_record(resolved_lock_path)Patch file: status_virtiofs_fix.patch — 20 lines, 1 hunk, -p1. Verified: patch --dry-run -p1 applies cleanly to upstream v2026.6.12.
Are you willing to submit a PR for this?
- I'd like to fix this myself and submit a PR
Activity
GottZ commentedon Jul 29, 2026
Summary
One PR addresses #46788. #46812 directly removes the missing-lock early exit so a live PID can still be detected, while current main now covers the same reported liveness failure through a stronger persisted runtime-state fallback.
Related pull requests
best fix— (+70/-5) — fixes, but superseded on main: the diff directly addresses the virtiofs cause by falling through to validated PID-file liveness when the lock path is absent, while preserving stale cleanup when an unlocked lock file still exists, with regression coverage for both cases. It remains relevant as the focused reference fix, but contributor review documents that commit 044996e, included in v2026.7.1, already implements the missing-lock liveness behavior through gateway_state.json.Suggested consolidation
Keep #46812 closed rather than reopening or merging it: despite the earlier APPROVED review on #46812, the later contributor review identifies the concrete mainline implementation and tests that supersede this patch. Treat #46812 as the best focused reference diff for #46788, with no duplicate PRs requiring closure.
Complex graph
flowchart LR classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937 classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151 classDef best stroke-width:3px,stroke:#b45309 classDef target stroke-width:3px,stroke:#4338ca I46788(["issue #46788 (open)"]) P46812["PR #46812 (closed)"] P46812 -->|best fix| I46788 class I46788 open class I46788 target class P46812 closed class P46812 best click I46788 "https://github.com/NousResearch/hermes-agent/issues/46788" click P46812 "https://github.com/NousResearch/hermes-agent/pull/46812"Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed or no verify verdict yet (state tag in the node label).
Cross-PR triage: Reviewed 1 pull request and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 5 kB of PR diffs, 9 kB of issue/PR text, 1 kB of discussion (2 comments), 2 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.