diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/finish b/docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/finish index d759815c0..d83c1a6e6 100755 --- a/docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/finish +++ b/docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/finish @@ -22,10 +22,9 @@ elif [[ "${exit_code_service}" -ne 0 ]]; then echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode fi else - # If the service exited with code 0, then we want to set the container exit code to 1 - if [[ "${exit_code_container}" -eq 0 ]]; then - echo "1" > /run/s6-linux-init-container-results/exitcode - fi + # Exit code 0 is expected when Frigate is restarted by the user. In this case, + # we create a signal for the go2rtc finish script to tolerate the restart. + touch /dev/shm/restarting-frigate fi exec /run/s6/basedir/bin/halt diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/finish b/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/finish index 9ebb6375e..26b34294a 100755 --- a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/finish +++ b/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/finish @@ -22,8 +22,9 @@ elif [[ "${exit_code_service}" -ne 0 ]]; then echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode fi else - # If the service exited with code 0, then we want to set the container exit code to 1 if it's 0 - if [[ "${exit_code_container}" -eq 0 ]]; then + # go2rtc is not supposed to exit, so even when it exits with 0 we make the + # container with 1. We only tolerate it when Frigate is restarting. + if [[ "${exit_code_container}" -eq 0 && ! -f /dev/shm/restarting-frigate ]]; then echo "1" > /run/s6-linux-init-container-results/exitcode fi fi diff --git a/frigate/http.py b/frigate/http.py index a83b94751..16a121af6 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -769,7 +769,7 @@ def config_save(): logging.error(f"Error restarting Frigate: {e}") return "Config successfully saved, unable to restart Frigate", 200 - return "Config successfully saved, restarting...", 200 + return "Config successfully saved, restarting (this can take up to one minute)...", 200 else: return "Config successfully saved.", 200 diff --git a/frigate/util.py b/frigate/util.py index 69ead2a7a..2987099e8 100755 --- a/frigate/util.py +++ b/frigate/util.py @@ -628,13 +628,8 @@ def clipped(obj, frame_shape): def restart_frigate(): - 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) + # S6 overlay is configured to exit once the Frigate process exits + os.kill(os.getpid(), signal.SIGTERM) class EventsPerSecond: diff --git a/web/src/AppBar.jsx b/web/src/AppBar.jsx index 95a6bfbf2..b5bb16c0f 100644 --- a/web/src/AppBar.jsx +++ b/web/src/AppBar.jsx @@ -78,7 +78,7 @@ export default function AppBar() { {showDialogWait ? ( ) : null}