Skip to content

Restart dashboard systemd unit after hermes update if one is installed - #69044

Closed
rahlquist wants to merge 2 commits into
NousResearch:mainfrom
rahlquist:fix/dashboard-restart-after-update
Closed

Restart dashboard systemd unit after hermes update if one is installed#69044
rahlquist wants to merge 2 commits into
NousResearch:mainfrom
rahlquist:fix/dashboard-restart-after-update

Conversation

@rahlquist

Copy link
Copy Markdown

Problem

hermes update only auto-restarts hermes-gateway* systemd units. The web dashboard is killed by PID at the end of the update and never relaunched, so users who run the dashboard as a systemd service (hermes-dashboard.service, per the dashboard docs / packaging) end up with a silently dead dashboard after every update.

Root cause confirmed in hermes_cli/main.py:

  • the gateway restart block lists only hermes-gateway* units (line ~11184),
  • _kill_stale_dashboard_processes() (line ~6428) SIGTERMs the dashboard PID and prints a manual relaunch hint, with an explicit comment that the dashboard "has no service manager".

Fix

Add _restart_dashboard_via_service_manager(). At the end of the update, instead of unconditionally PID-killing the dashboard, it:

  1. Probes for an active hermes-dashboard* systemd unit in both --user and system scope (systemctl list-units hermes-dashboard*).
  2. If found, restarts it via the same reset-failed -> restart (+ one retry) -> is-active poll path already used for gateways, including the non-interactive sudo -n privilege probe so it cannot hang on a polkit prompt.
  3. Falls back to the existing PID-kill (_kill_stale_dashboard_processes) only when no systemd unit owns the dashboard — i.e. the upstream default (no service manager) behavior is fully preserved.

Scope note: systemd-only. There is no standardized upstream launchd label for the dashboard (only the gateway has get_launchd_label()), so adding launchd guesswork would be speculative. Linux systemd units are the real, reproducible case.

Verification

  • Patch generated against HEAD 75be8fb46 (live install) and against the fresh fork clone (32a9f2a); git apply --check passes in both.
  • Edited module ast.parse-valid.
  • Local unit workaround (Restart=always) confirmed working independently on the reporter's machine.

Test plan

  • On a machine with hermes-dashboard.service active: hermes update restarts it (visible in systemctl --user status hermes-dashboard).
  • On a machine without a dashboard unit: behavior unchanged (legacy PID-kill + manual relaunch hint).

`hermes update` only auto-restarts hermes-gateway* units; the dashboard is
killed by PID and never relaunched, so users who installed a
hermes-dashboard.service (systemd docs / packaging) get a silently dead
dashboard after every update.

Add `_restart_dashboard_via_service_manager()`, which probes for an active
hermes-dashboard* systemd unit in both --user and system scope and restarts
it via the same reset-failed -> restart (+ retry) -> is-active poll path used
for gateways, including the non-interactive sudo -n privilege probe. When no
systemd unit owns the dashboard, fall back to the existing PID-kill so the
default (no service manager) behavior is unchanged.

Fixes: dashboard not auto-restarting after `hermes update` when run as a
systemd service.
Covers `_restart_dashboard_via_service_manager()` (added by the sibling
fix commit):
- no systemd support -> returns False (PID-kill fallback)
- no hermes-dashboard* unit -> returns False
- active user-scope unit -> restart issued (reset-failed + restart) + True
- system-scope unit without non-interactive sudo -> skips, prints manual
  hint, returns True (no polkit hang)
- first restart fails -> retries once and succeeds
- inactive unit -> ignored, not restarted

All 28 tests in the file pass; the new class is 6 tests.
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard area/install-update Installer, updater, packaging, wheels, doctor sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades needs-decision Awaiting maintainer decision before any implementation labels Jul 22, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: #40616 and #39166 address the same dashboard-update/systemd lifecycle. This patch uses active-unit discovery and restart-before-PID cleanup, while #40616 validates service ExecStart after cleanup; maintainer direction is needed on the intended service-management policy.

@rahlquist

Copy link
Copy Markdown
Author

Apologies for the duplication

@rahlquist

Copy link
Copy Markdown
Author

Closing as a duplicate of #40616 and #39166, which cover the same hermes update dashboard systemd restart. My local instance is already handled by Restart=always on the dashboard unit, so there is no personal need remaining. Apologies for the noise — maintainers should take whichever approach they prefer from the existing PRs.

@rahlquist rahlquist closed this Jul 22, 2026
@rahlquist
rahlquist deleted the fix/dashboard-restart-after-update branch July 22, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/install-update Installer, updater, packaging, wheels, doctor comp/cli CLI entry point, hermes_cli/, setup wizard needs-decision Awaiting maintainer decision before any implementation P3 Low — cosmetic, nice to have sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants