diff --git a/controller/lib/systemd.py b/controller/lib/systemd.py index 28a6f700..37ee2f09 100644 --- a/controller/lib/systemd.py +++ b/controller/lib/systemd.py @@ -226,6 +226,26 @@ def restart_service(name: str) -> dict: return {"success": False, "error": f"Unknown service: {name}"} systemd_name = service_config.get("systemd_name", name) + + # Special handling for self-restart: use Popen to avoid blocking + # (the process will be killed before subprocess.run can return) + if systemd_name == "wrolpi-controller": + try: + subprocess.Popen(["systemctl", "restart", systemd_name]) + return { + "success": True, + "service": name, + "action": "restart", + "pending": True, + } + except Exception as e: + return { + "success": False, + "service": name, + "action": "restart", + "error": str(e), + } + result = _run_systemctl("restart", systemd_name) return { diff --git a/controller/templates/index.html b/controller/templates/index.html index 30a79a1f..4553deb3 100644 --- a/controller/templates/index.html +++ b/controller/templates/index.html @@ -730,7 +730,7 @@