Set titles for forked processes

This commit is contained in:
Nat Morris 2021-01-03 19:41:02 +00:00 committed by Blake Blackshear
parent 76403bba8e
commit 4619836122
5 changed files with 11 additions and 3 deletions

View File

@ -32,7 +32,8 @@ RUN pip3 wheel --wheel-dir=/wheels \
paho-mqtt \ paho-mqtt \
PyYAML \ PyYAML \
matplotlib \ matplotlib \
click click \
setproctitle
FROM scratch FROM scratch

View File

@ -42,7 +42,8 @@ RUN pip3 wheel --wheel-dir=/wheels \
paho-mqtt \ paho-mqtt \
PyYAML \ PyYAML \
matplotlib \ matplotlib \
click click \
setproctitle
FROM scratch FROM scratch

View File

@ -8,6 +8,7 @@ import threading
import signal import signal
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from multiprocessing.connection import Connection from multiprocessing.connection import Connection
from setproctitle import setproctitle
from typing import Dict from typing import Dict
import numpy as np import numpy as np
@ -110,6 +111,7 @@ def run_detector(name: str, detection_queue: mp.Queue, out_events: Dict[str, mp.
threading.current_thread().name = f"detector:{name}" threading.current_thread().name = f"detector:{name}"
logger = logging.getLogger(f"detector.{name}") logger = logging.getLogger(f"detector.{name}")
logger.info(f"Starting detection process: {os.getpid()}") logger.info(f"Starting detection process: {os.getpid()}")
setproctitle(f"frigate.detector.{name}")
listen() listen()
stop_event = mp.Event() stop_event = mp.Event()

View File

@ -6,6 +6,7 @@ import signal
import queue import queue
import multiprocessing as mp import multiprocessing as mp
from logging import handlers from logging import handlers
from setproctitle import setproctitle
def listener_configurer(): def listener_configurer():
@ -31,6 +32,7 @@ def log_process(log_queue):
signal.signal(signal.SIGINT, receiveSignal) signal.signal(signal.SIGINT, receiveSignal)
threading.current_thread().name = f"logger" threading.current_thread().name = f"logger"
setproctitle("frigate.logger")
listener_configurer() listener_configurer()
while True: while True:
if stop_event.is_set() and log_queue.empty(): if stop_event.is_set() and log_queue.empty():

View File

@ -13,6 +13,7 @@ import signal
import threading import threading
import time import time
from collections import defaultdict from collections import defaultdict
from setproctitle import setproctitle
from typing import Dict, List from typing import Dict, List
import cv2 import cv2
@ -249,6 +250,7 @@ def track_camera(name, config: CameraConfig, model_shape, detection_queue, resul
signal.signal(signal.SIGINT, receiveSignal) signal.signal(signal.SIGINT, receiveSignal)
threading.current_thread().name = f"process:{name}" threading.current_thread().name = f"process:{name}"
setproctitle(f"frigate.process:{name}")
listen() listen()
frame_queue = process_info['frame_queue'] frame_queue = process_info['frame_queue']