fix graceful exits

This commit is contained in:
Blake Blackshear 2020-12-05 11:14:18 -06:00
parent 2d016be86e
commit 3b166d6300
2 changed files with 10 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import os
from logging.handlers import QueueHandler from logging.handlers import QueueHandler
from typing import Dict, List from typing import Dict, List
import sys import sys
import signal
import yaml import yaml
from playhouse.sqlite_ext import SqliteExtDatabase from playhouse.sqlite_ext import SqliteExtDatabase
@ -46,6 +47,7 @@ class FrigateApp():
def init_logger(self): def init_logger(self):
self.log_process = mp.Process(target=log_process, args=(self.log_queue,), name='log_process') self.log_process = mp.Process(target=log_process, args=(self.log_queue,), name='log_process')
self.log_process.daemon = True
self.log_process.start() self.log_process.start()
root_configurer(self.log_queue) root_configurer(self.log_queue)
@ -173,6 +175,13 @@ class FrigateApp():
self.start_recording_maintainer() self.start_recording_maintainer()
self.start_watchdog() self.start_watchdog()
self.zeroconf = broadcast_zeroconf(self.config.mqtt.client_id) self.zeroconf = broadcast_zeroconf(self.config.mqtt.client_id)
def receiveSignal(signalNumber, frame):
self.stop()
sys.exit()
signal.signal(signal.SIGTERM, receiveSignal)
self.flask_app.run(host='127.0.0.1', port=5001, debug=False) self.flask_app.run(host='127.0.0.1', port=5001, debug=False)
self.stop() self.stop()

2
run.sh
View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
service nginx start service nginx start
python3 -u -m frigate exec python3 -u -m frigate