From 40c40f81fc358c334872a0259e8f19c158db8e58 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Sat, 14 Feb 2026 12:23:08 +0100 Subject: [PATCH] Update flask_auth_routes.py --- AppImage/scripts/flask_auth_routes.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/AppImage/scripts/flask_auth_routes.py b/AppImage/scripts/flask_auth_routes.py index 5a40d6df..254cb76b 100644 --- a/AppImage/scripts/flask_auth_routes.py +++ b/AppImage/scripts/flask_auth_routes.py @@ -5,8 +5,7 @@ Provides REST API endpoints for authentication management import logging import os -import signal -import sys +import subprocess import threading import time from flask import Blueprint, jsonify, request @@ -79,16 +78,23 @@ def ssl_status(): def _schedule_service_restart(delay=1.5): - """Schedule a self-restart of the Flask server after a short delay. - This gives time for the HTTP response to reach the client before the process exits. - The process will be restarted by the parent (systemd, AppRun, or manual).""" + """Schedule a restart of the monitor service via systemctl after a short delay. + This gives time for the HTTP response to reach the client before the process restarts.""" def _do_restart(): time.sleep(delay) print("[ProxMenux] Restarting monitor service to apply SSL changes...") - # Send SIGTERM to our own process - this triggers a clean shutdown. - # If running under systemd with Restart=always, it will auto-restart. - # If running directly, the process exits (user must restart manually as fallback). - os.kill(os.getpid(), signal.SIGTERM) + # Use systemctl restart which properly stops and starts the service. + # This works because systemd manages proxmenux-monitor.service. + try: + subprocess.Popen( + ["systemctl", "restart", "proxmenux-monitor"], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL + ) + except Exception as e: + print(f"[ProxMenux] Failed to restart via systemctl: {e}") + # Fallback: try to restart the process directly + os.kill(os.getpid(), 15) # SIGTERM t = threading.Thread(target=_do_restart, daemon=True) t.start()