forked from Github/frigate
Fast restart (#5378)
* dont wait so long for queues * implement stop methods for comms * set the detection events on exit and return early from processing * handle the stop event in the broadcast threads * short circuit the detection process exit code if it already exited * some logging for stats thread * just keep the log process alive 1 second after the last log message * ensure the multiprocessing queues are emptied and closed * Update frigate/log.py Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com> * Update frigate/log.py Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com> * mypy fixes --------- Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
This commit is contained in:
@@ -2,11 +2,16 @@
|
||||
import logging
|
||||
import threading
|
||||
import os
|
||||
import signal
|
||||
import queue
|
||||
import multiprocessing as mp
|
||||
from multiprocessing.queues import Queue
|
||||
from logging import handlers
|
||||
from typing import Optional
|
||||
from types import FrameType
|
||||
from setproctitle import setproctitle
|
||||
from typing import Deque
|
||||
from typing import Deque, Optional
|
||||
from types import FrameType
|
||||
from collections import deque
|
||||
|
||||
from frigate.util import clean_camera_user_pass
|
||||
@@ -34,10 +39,21 @@ def log_process(log_queue: Queue) -> None:
|
||||
threading.current_thread().name = f"logger"
|
||||
setproctitle("frigate.logger")
|
||||
listener_configurer()
|
||||
|
||||
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)
|
||||
|
||||
while True:
|
||||
try:
|
||||
record = log_queue.get(timeout=5)
|
||||
record = log_queue.get(timeout=1)
|
||||
except (queue.Empty, KeyboardInterrupt):
|
||||
if stop_event.is_set():
|
||||
break
|
||||
continue
|
||||
logger = logging.getLogger(record.name)
|
||||
logger.handle(record)
|
||||
|
||||
Reference in New Issue
Block a user