feat: restart button in settings via atexit+execv
This commit is contained in:
+9
-3
@@ -389,9 +389,6 @@ async def api_import_backup(file: UploadFile = File(...)):
|
||||
|
||||
from config.settings import reload_config
|
||||
reload_config()
|
||||
from models.dashboard import dashboard_manager
|
||||
import importlib
|
||||
importlib.reload(__import__('models.dashboard', fromlist=['dashboard_manager']))
|
||||
from server.game_manager import game_plugin_manager
|
||||
game_plugin_manager.reload()
|
||||
|
||||
@@ -400,6 +397,15 @@ async def api_import_backup(file: UploadFile = File(...)):
|
||||
return {"ok": False, "message": str(e)}
|
||||
|
||||
|
||||
# ---- Restart ----
|
||||
@router.post("/restart")
|
||||
async def api_restart():
|
||||
import os, sys, atexit
|
||||
logger.info("Restart requested via API")
|
||||
atexit.register(lambda: os.execv(sys.executable, [sys.executable] + sys.argv))
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
# ---- Data Forwarding ----
|
||||
@router.get("/forward")
|
||||
async def api_list_forward_targets():
|
||||
|
||||
Reference in New Issue
Block a user