From b267e3409212a8cdd110960a3e9b784b126077e5 Mon Sep 17 00:00:00 2001 From: teknium1 Date: Thu, 26 Feb 2026 20:26:05 -0800 Subject: [PATCH] feat(cli): add auto-restart functionality for hermes-gateway service when updating - Implemented a check to determine if the hermes-gateway service is active after an update. - Added logic to automatically restart the service if it is running, ensuring changes are applied without manual intervention. - Updated user guidance to reflect the new auto-restart feature, removing the need for manual restart instructions. --- hermes_cli/main.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/hermes_cli/main.py b/hermes_cli/main.py index 03c739d5..b232d5b5 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -754,12 +754,31 @@ def cmd_update(args): print() print("✓ Update complete!") + + # Auto-restart gateway if it's running as a systemd service + try: + check = subprocess.run( + ["systemctl", "--user", "is-active", "hermes-gateway"], + capture_output=True, text=True, timeout=5, + ) + if check.stdout.strip() == "active": + print() + print("→ Gateway service is running — restarting to pick up changes...") + restart = subprocess.run( + ["systemctl", "--user", "restart", "hermes-gateway"], + capture_output=True, text=True, timeout=15, + ) + if restart.returncode == 0: + print("✓ Gateway restarted.") + else: + print(f"⚠ Gateway restart failed: {restart.stderr.strip()}") + print(" Try manually: hermes gateway restart") + except (FileNotFoundError, subprocess.TimeoutExpired): + pass # No systemd (macOS, WSL1, etc.) — skip silently + print() print("Tip: You can now log in with Nous Portal for inference:") print(" hermes login # Authenticate with Nous Portal") - print() - print("Note: If you have the gateway service running, restart it:") - print(" hermes gateway restart") except subprocess.CalledProcessError as e: print(f"✗ Update failed: {e}")