diff --git a/frigate/app.py b/frigate/app.py index a0387ead8..01df49828 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -5,6 +5,7 @@ import os from logging.handlers import QueueHandler from typing import Dict, List import sys +import signal import yaml from playhouse.sqlite_ext import SqliteExtDatabase @@ -46,6 +47,7 @@ class FrigateApp(): def init_logger(self): self.log_process = mp.Process(target=log_process, args=(self.log_queue,), name='log_process') + self.log_process.daemon = True self.log_process.start() root_configurer(self.log_queue) @@ -173,6 +175,13 @@ class FrigateApp(): self.start_recording_maintainer() self.start_watchdog() 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.stop() diff --git a/run.sh b/run.sh index 52277327b..4ad3587e1 100644 --- a/run.sh +++ b/run.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash service nginx start -python3 -u -m frigate \ No newline at end of file +exec python3 -u -m frigate \ No newline at end of file