mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-15 07:35:27 +03:00
Register SIGTERM handler in main
This commit is contained in:
parent
aa62a0be11
commit
13e6e36812
@ -1,6 +1,7 @@
|
||||
import argparse
|
||||
import faulthandler
|
||||
import logging
|
||||
import signal
|
||||
import sys
|
||||
import threading
|
||||
|
||||
@ -24,6 +25,9 @@ def main() -> None:
|
||||
threading.current_thread().name = "frigate"
|
||||
cli.show_server_banner = lambda *x: None
|
||||
|
||||
# Make sure we exit cleanly on SIGTERM.
|
||||
signal.signal(signal.SIGTERM, lambda sig, frame: sys.exit())
|
||||
|
||||
# Parse the cli arguments.
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="Frigate",
|
||||
|
||||
@ -4,12 +4,10 @@ import multiprocessing as mp
|
||||
import os
|
||||
import secrets
|
||||
import shutil
|
||||
import signal
|
||||
import sys
|
||||
from multiprocessing import Queue
|
||||
from multiprocessing.synchronize import Event as MpEvent
|
||||
from types import FrameType
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
import psutil
|
||||
from peewee_migrate import Router
|
||||
@ -678,12 +676,6 @@ class FrigateApp:
|
||||
self.start_watchdog()
|
||||
self.init_auth()
|
||||
|
||||
# Flask only listens for SIGINT, so we need to catch SIGTERM and send SIGINT
|
||||
def receiveSignal(signalNumber: int, frame: Optional[FrameType]) -> None:
|
||||
os.kill(os.getpid(), signal.SIGINT)
|
||||
|
||||
signal.signal(signal.SIGTERM, receiveSignal)
|
||||
|
||||
try:
|
||||
self.flask_app.run(host="127.0.0.1", port=5001, debug=False, threaded=True)
|
||||
except KeyboardInterrupt:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user