Skip to content

Commit

Permalink
use s6 to shutdown frigate
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeblackshear committed Sep 18, 2021
1 parent 96319e7 commit a943ac1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 8 additions & 1 deletion frigate/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import matplotlib.pyplot as plt
import numpy as np
import os
import psutil

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -534,7 +535,13 @@ def clipped(obj, frame_shape):


def restart_frigate():
os.kill(os.getpid(), signal.SIGTERM)
proc = psutil.Process(1)
# if this is running via s6, sigterm pid 1
if proc.name() == "s6-svscan":
proc.terminate()
# otherwise, just try and exit frigate
else:
os.kill(os.getpid(), signal.SIGTERM)


class EventsPerSecond:
Expand Down
6 changes: 5 additions & 1 deletion frigate/watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import os
import signal

from frigate.util import (
restart_frigate,
)

logger = logging.getLogger(__name__)


Expand All @@ -30,6 +34,6 @@ def run(self):
detector.start_or_restart()
elif not detector.detect_process.is_alive():
logger.info("Detection appears to have stopped. Exiting frigate...")
os.kill(os.getpid(), signal.SIGTERM)
restart_frigate()

logger.info(f"Exiting watchdog...")

0 comments on commit a943ac1

Please sign in to comment.