From 461983612243a990d319c1d45068d686aedcd35a Mon Sep 17 00:00:00 2001 From: Nat Morris Date: Sun, 3 Jan 2021 19:41:02 +0000 Subject: [PATCH] Set titles for forked processes --- docker/Dockerfile.wheels | 3 ++- docker/Dockerfile.wheels.aarch64 | 3 ++- frigate/edgetpu.py | 2 ++ frigate/log.py | 4 +++- frigate/video.py | 2 ++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile.wheels b/docker/Dockerfile.wheels index 15f244671..02ddb3f8a 100644 --- a/docker/Dockerfile.wheels +++ b/docker/Dockerfile.wheels @@ -32,7 +32,8 @@ RUN pip3 wheel --wheel-dir=/wheels \ paho-mqtt \ PyYAML \ matplotlib \ - click + click \ + setproctitle FROM scratch diff --git a/docker/Dockerfile.wheels.aarch64 b/docker/Dockerfile.wheels.aarch64 index 006f569cf..6a6f988a2 100644 --- a/docker/Dockerfile.wheels.aarch64 +++ b/docker/Dockerfile.wheels.aarch64 @@ -42,7 +42,8 @@ RUN pip3 wheel --wheel-dir=/wheels \ paho-mqtt \ PyYAML \ matplotlib \ - click + click \ + setproctitle FROM scratch diff --git a/frigate/edgetpu.py b/frigate/edgetpu.py index f2df756a5..79ba626f6 100644 --- a/frigate/edgetpu.py +++ b/frigate/edgetpu.py @@ -8,6 +8,7 @@ import threading import signal from abc import ABC, abstractmethod from multiprocessing.connection import Connection +from setproctitle import setproctitle from typing import Dict 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}" logger = logging.getLogger(f"detector.{name}") logger.info(f"Starting detection process: {os.getpid()}") + setproctitle(f"frigate.detector.{name}") listen() stop_event = mp.Event() diff --git a/frigate/log.py b/frigate/log.py index 8bd01ae56..d514fb0bd 100644 --- a/frigate/log.py +++ b/frigate/log.py @@ -6,6 +6,7 @@ import signal import queue import multiprocessing as mp from logging import handlers +from setproctitle import setproctitle def listener_configurer(): @@ -31,6 +32,7 @@ def log_process(log_queue): signal.signal(signal.SIGINT, receiveSignal) threading.current_thread().name = f"logger" + setproctitle("frigate.logger") listener_configurer() while True: if stop_event.is_set() and log_queue.empty(): @@ -72,4 +74,4 @@ class LogPipe(threading.Thread): def close(self): """Close the write end of the pipe. """ - os.close(self.fdWrite) \ No newline at end of file + os.close(self.fdWrite) diff --git a/frigate/video.py b/frigate/video.py index 150ef4276..bbddaf5f6 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -13,6 +13,7 @@ import signal import threading import time from collections import defaultdict +from setproctitle import setproctitle from typing import Dict, List import cv2 @@ -249,6 +250,7 @@ def track_camera(name, config: CameraConfig, model_shape, detection_queue, resul signal.signal(signal.SIGINT, receiveSignal) threading.current_thread().name = f"process:{name}" + setproctitle(f"frigate.process:{name}") listen() frame_queue = process_info['frame_queue']