Disable detect in config before restart

This commit is contained in:
Nick Mowen 2023-02-03 08:39:13 -07:00
parent ea8ec23cbe
commit 09c39f8040
4 changed files with 13 additions and 7 deletions

View File

@ -65,7 +65,7 @@ class Dispatcher:
logger.error(f"Received invalid set command: {topic}") logger.error(f"Received invalid set command: {topic}")
return return
elif topic == "restart": elif topic == "restart":
restart_frigate() restart_frigate(self.config)
def publish(self, topic: str, payload: Any, retain: bool = False) -> None: def publish(self, topic: str, payload: Any, retain: bool = False) -> None:
"""Handle publishing to communicators.""" """Handle publishing to communicators."""

View File

@ -764,7 +764,7 @@ def config_save():
if save_option == "restart": if save_option == "restart":
try: try:
restart_frigate() restart_frigate(current_app.frigate_config)
except Exception as e: except Exception as e:
logging.error(f"Error restarting Frigate: {e}") logging.error(f"Error restarting Frigate: {e}")
return "Config successfully saved, unable to restart Frigate", 200 return "Config successfully saved, unable to restart Frigate", 200

View File

@ -22,6 +22,7 @@ import os
import psutil import psutil
import pytz import pytz
from frigate.config import FrigateConfig
from frigate.const import REGEX_HTTP_CAMERA_USER_PASS, REGEX_RTSP_CAMERA_USER_PASS from frigate.const import REGEX_HTTP_CAMERA_USER_PASS, REGEX_RTSP_CAMERA_USER_PASS
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -627,7 +628,11 @@ def clipped(obj, frame_shape):
return False return False
def restart_frigate(): def restart_frigate(config: FrigateConfig):
# disable detect for cameras to speed up restart
for _, camera in config.cameras.items():
camera.detect.enabled = False
proc = psutil.Process(1) proc = psutil.Process(1)
# if this is running via s6, sigterm pid 1 # if this is running via s6, sigterm pid 1
if proc.name() == "s6-svscan": if proc.name() == "s6-svscan":

View File

@ -2,20 +2,21 @@ import datetime
import logging import logging
import threading import threading
import time import time
import os
import signal
from multiprocessing.synchronize import Event as MpEvent
from frigate.config import FrigateConfig
from frigate.object_detection import ObjectDetectProcess from frigate.object_detection import ObjectDetectProcess
from frigate.util import restart_frigate from frigate.util import restart_frigate
from multiprocessing.synchronize import Event as MpEvent
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class FrigateWatchdog(threading.Thread): class FrigateWatchdog(threading.Thread):
def __init__(self, detectors: dict[str, ObjectDetectProcess], stop_event: MpEvent): def __init__(self, config: FrigateConfig, detectors: dict[str, ObjectDetectProcess], stop_event: MpEvent):
threading.Thread.__init__(self) threading.Thread.__init__(self)
self.name = "frigate_watchdog" self.name = "frigate_watchdog"
self.config = config
self.detectors = detectors self.detectors = detectors
self.stop_event = stop_event self.stop_event = stop_event