feat: bouton restart photobooth-app après modification des actions
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""API de surveillance des ressources système."""
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
from typing import Optional
|
||||
from fastapi import APIRouter, Request, Body
|
||||
@@ -9,6 +10,16 @@ from pydantic import BaseModel
|
||||
logger = logging.getLogger(__name__)
|
||||
router = APIRouter()
|
||||
|
||||
# Services autorisés pour le restart individuel (jh-photomaton a son propre endpoint)
|
||||
_ALLOWED_SERVICES = {
|
||||
"photobooth-app",
|
||||
"photobooth-kiosk",
|
||||
"zoraxy",
|
||||
"hostapd",
|
||||
"dnsmasq",
|
||||
"cups",
|
||||
}
|
||||
|
||||
|
||||
@router.get("/system/stats")
|
||||
async def system_stats(request: Request):
|
||||
@@ -90,7 +101,15 @@ async def _restart_photobooth():
|
||||
stderr=asyncio.subprocess.DEVNULL,
|
||||
)
|
||||
await proc.wait()
|
||||
logger.info("photobooth-app redémarré après changement CSS")
|
||||
logger.info("photobooth-app redémarré")
|
||||
|
||||
|
||||
@router.post("/system/restart-photobooth")
|
||||
async def restart_photobooth(request: Request):
|
||||
"""Redémarre photobooth-app.service pour recharger la config (actions, etc.)."""
|
||||
import asyncio
|
||||
asyncio.create_task(_restart_photobooth())
|
||||
return {"ok": True, "message": "Redémarrage de photobooth-app en cours…"}
|
||||
|
||||
|
||||
@router.post("/system/screen/refresh")
|
||||
|
||||
Reference in New Issue
Block a user