mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-12-19 19:06:16 +01:00
dc54981784
* Moved FrigateApp.init_config() into FrigateConfig.load() * Move frigate config loading into main * Store PlusApi in FrigateConfig * Register SIGTERM handler in main * Ensure logging is setup during config parsing * Removed pointless try * Moved config initialization out of FrigateApp * Made FrigateApp.shm_frame_count into a function * Removed log calls from signal handlers python's logging calls are not re-entrant, which caused at least one of these to deadlock randomly. * Reopen stdout/err on process fork This helps avoid deadlocks (https://github.com/python/cpython/issues/91776). * Make mypy happy * Whoops. I might have forgotten to save. Truly an amateur mistake. * Always call FrigateApp.stop()
37 lines
933 B
Python
37 lines
933 B
Python
"""Run recording maintainer and cleanup."""
|
|
|
|
import logging
|
|
import multiprocessing as mp
|
|
import signal
|
|
import threading
|
|
from types import FrameType
|
|
from typing import Optional
|
|
|
|
from setproctitle import setproctitle
|
|
|
|
from frigate.config import FrigateConfig
|
|
from frigate.review.maintainer import ReviewSegmentMaintainer
|
|
from frigate.util.services import listen
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def manage_review_segments(config: FrigateConfig) -> None:
|
|
stop_event = mp.Event()
|
|
|
|
def receiveSignal(signalNumber: int, frame: Optional[FrameType]) -> None:
|
|
stop_event.set()
|
|
|
|
signal.signal(signal.SIGTERM, receiveSignal)
|
|
signal.signal(signal.SIGINT, receiveSignal)
|
|
|
|
threading.current_thread().name = "process:review_segment_manager"
|
|
setproctitle("frigate.review_segment_manager")
|
|
listen()
|
|
|
|
maintainer = ReviewSegmentMaintainer(
|
|
config,
|
|
stop_event,
|
|
)
|
|
maintainer.start()
|