mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
allow logger daemon process to be killed with the main thread, thus allowing us to continue logging during shutdown
This commit is contained in:
parent
3a171d19e3
commit
482399d82f
@ -1,10 +1,8 @@
|
||||
{
|
||||
"name": "Frigate Dev",
|
||||
"context": "..",
|
||||
"dockerComposeFile": "../docker-compose.yml",
|
||||
"service": "dev",
|
||||
"workspaceFolder": "/opt/frigate",
|
||||
"shutdownAction": "stopCompose",
|
||||
"extensions": [
|
||||
"ms-python.python",
|
||||
"visualstudioexptteam.vscodeintellicode",
|
||||
|
@ -14,6 +14,10 @@ services:
|
||||
- .:/opt/frigate:cached
|
||||
- ./config/config.yml:/config/config.yml:ro
|
||||
- ./debug:/media/frigate
|
||||
- type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
|
||||
target: /tmp/cache
|
||||
tmpfs:
|
||||
size: 1000000000
|
||||
ports:
|
||||
- "1935:1935"
|
||||
- "5000:5000"
|
||||
|
@ -13,7 +13,9 @@ from collections import deque
|
||||
def listener_configurer():
|
||||
root = logging.getLogger()
|
||||
console_handler = logging.StreamHandler()
|
||||
formatter = logging.Formatter("%(name)-30s %(levelname)-8s: %(message)s")
|
||||
formatter = logging.Formatter(
|
||||
"[%(asctime)s] %(name)-30s %(levelname)-8s: %(message)s", "%Y-%m-%d %H:%M:%S"
|
||||
)
|
||||
console_handler.setFormatter(formatter)
|
||||
root.addHandler(console_handler)
|
||||
root.setLevel(logging.INFO)
|
||||
@ -27,20 +29,10 @@ def root_configurer(queue):
|
||||
|
||||
|
||||
def log_process(log_queue):
|
||||
stop_event = mp.Event()
|
||||
|
||||
def receiveSignal(signalNumber, frame):
|
||||
stop_event.set()
|
||||
|
||||
signal.signal(signal.SIGTERM, receiveSignal)
|
||||
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():
|
||||
break
|
||||
try:
|
||||
record = log_queue.get(timeout=5)
|
||||
except queue.Empty:
|
||||
|
Loading…
Reference in New Issue
Block a user