HCI gateway status detection should not depend entirely on systemctl
HCI gateway status detection should not depend entirely on systemctl
Summary
I ran into a gateway-status issue on a host where Hermes is healthy and reachable, but not managed by systemd.
HCI was able to reach the Hermes Gateway API, but parts of the UI still reported the gateway as stopped or disabled because they appeared to rely on systemctl as the source of truth.
This seems like a general compatibility issue for non-systemd installs, not just a host-specific edge case.
Environment
- HCI version:
v3.4.2 - Hermes gateway API enabled and healthy
- Hermes managed outside
systemd - Example setup: a supervisor-managed Hermes gateway exposing a healthy local API on
127.0.0.1:8642
What I saw
Initially, HCI could not discover the gateway port for default, fell back to CLI mode, and showed Gateway API Enabled as disabled.
After declaring the API server in Hermes config:
platforms:
api_server:
enabled: true
extra:
host: 127.0.0.1
port: 8642
HCI started discovering the gateway correctly.
At that point:
- HCI discovered
default: 8642 - the gateway health endpoints returned
200 - profile-level gateway checks could look healthy
But some parts of the UI, especially summary/service-status views, still showed the gateway as stopped or disabled.
Why this seems to happen
From what I could tell, HCI has a few different gateway-status paths:
-
API/gateway discovery
- based on config, discovered port, and API reachability
-
Gateway service card / diagnostics
- in some places based on
systemctl is-active,systemctl is-enabled, andsystemctl status
- in some places based on
-
Home/dashboard summary
- in some places based on
systemctl is-active hermes-gateway
- in some places based on
So the API side can be healthy while the UI still shows a false negative status because systemctl is being treated as the main signal.
Expected behavior
If Hermes config declares an API server and HCI can confirm that:
- the configured port exists
- the local health endpoint responds successfully
then HCI should treat the gateway as running, even if there is no systemd unit behind it.
Similarly:
Enabledshould come from config whenplatforms.api_server.enabledis presentsystemctlshould be a fallback for installs that actually use it, not the default truth source for every environment
Suggested approach
For setups where an API server is configured:
- prefer
platforms.api_server.enabledoversystemctl is-enabled - prefer a successful local gateway health probe over
systemctl is-active - use a more generic service label when the gateway is not managed by
systemd - keep the current
systemctlbehavior as fallback when no configured API server is present
Why this would help
This would make HCI work better on:
- non-
systemdLinux hosts - containerized deployments
- custom supervisors
- externally managed Hermes runtimes
In all of those cases, the gateway can be perfectly healthy while systemctl is simply not relevant.
Final note
I am not suggesting removing systemctl support.
The issue is that systemctl seems to be assumed in some UI paths even when HCI already has a better signal available from config and the local gateway health endpoint.
✅ Fixed — commit f12abaa
Root Cause
HCI relied on systemctl is-active as the primary signal for gateway status. Non-systemd setups (container, supervisor, custom runtimes) showed gateway as "stopped" even when the API was healthy.
Changes
New: probeGatewayHealth(profile) — centralized health probe function:
- Probes gateway
/healthendpoint directly (3s timeout) - Falls back to
systemctlif no API configured - Returns
{ ok, managedBy: 'api' | 'systemd' | 'unknown' }
Updated 3 endpoints:
/api/agent/status— gateway status now uses API probe first, systemctl fallback/api/gateway/:profile— service card returnsmanagedByfield; API-healthy =active: true, enabled: true/api/gateway/:profile/health— 3-tier check: API probe → systemctl → port listening
Behavior
- Non-systemd setups: Gateway shows "running" if API health probe succeeds
- Systemd setups: Same behavior (systemctl still works as fallback)
- No API configured: Falls back to systemctl (backwards compatible)
- Response includes
managedBy:'api'|'systemd'|'unknown'— frontend can show appropriate labels
Tested
- Gateway health probe returns 200 on
http://127.0.0.1:8642/health - Systemctl fallback still works for systemd-managed gateways
- Merged to
main, deployed to staging