Pass stopevent from main start

This commit is contained in:
Nicolas Mowen 2025-06-23 17:39:21 -06:00
parent a22e24f24b
commit 9503e48313
2 changed files with 9 additions and 3 deletions

View File

@ -23,6 +23,10 @@ def main() -> None:
setup_logging(manager)
threading.current_thread().name = "frigate"
stop_event = mp.Event()
# send stop event on SIGINT
signal.signal(signal.SIGINT, lambda sig, frame: stop_event.set())
# Make sure we exit cleanly on SIGTERM.
signal.signal(signal.SIGTERM, lambda sig, frame: sys.exit())
@ -110,7 +114,7 @@ def main() -> None:
sys.exit(0)
# Run the main application.
FrigateApp(config, manager).start()
FrigateApp(config, manager, stop_event).start()
if __name__ == "__main__":

View File

@ -79,10 +79,12 @@ logger = logging.getLogger(__name__)
class FrigateApp:
def __init__(self, config: FrigateConfig, manager: SyncManager) -> None:
def __init__(
self, config: FrigateConfig, manager: SyncManager, stop_event: MpEvent
) -> None:
self.metrics_manager = manager
self.audio_process: Optional[mp.Process] = None
self.stop_event: MpEvent = mp.Event()
self.stop_event = stop_event
self.detection_queue: Queue = mp.Queue()
self.detectors: dict[str, ObjectDetectProcess] = {}
self.detection_shms: list[mp.shared_memory.SharedMemory] = []