Restart improvements

This commit is contained in:
Felipe Santos 2023-01-17 13:53:07 -03:00
parent 5feaa0461f
commit 92e702a33c
5 changed files with 10 additions and 15 deletions

View File

@ -22,10 +22,9 @@ elif [[ "${exit_code_service}" -ne 0 ]]; then
echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode
fi fi
else else
# If the service exited with code 0, then we want to set the container exit code to 1 # Exit code 0 is expected when Frigate is restarted by the user. In this case,
if [[ "${exit_code_container}" -eq 0 ]]; then # we create a signal for the go2rtc finish script to tolerate the restart.
echo "1" > /run/s6-linux-init-container-results/exitcode touch /dev/shm/restarting-frigate
fi
fi fi
exec /run/s6/basedir/bin/halt exec /run/s6/basedir/bin/halt

View File

@ -22,8 +22,9 @@ elif [[ "${exit_code_service}" -ne 0 ]]; then
echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode
fi fi
else else
# If the service exited with code 0, then we want to set the container exit code to 1 if it's 0 # go2rtc is not supposed to exit, so even when it exits with 0 we make the
if [[ "${exit_code_container}" -eq 0 ]]; then # 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 echo "1" > /run/s6-linux-init-container-results/exitcode
fi fi
fi fi

View File

@ -769,7 +769,7 @@ def config_save():
logging.error(f"Error restarting Frigate: {e}") logging.error(f"Error restarting Frigate: {e}")
return "Config successfully saved, unable to restart Frigate", 200 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: else:
return "Config successfully saved.", 200 return "Config successfully saved.", 200

View File

@ -628,13 +628,8 @@ def clipped(obj, frame_shape):
def restart_frigate(): def restart_frigate():
proc = psutil.Process(1) # S6 overlay is configured to exit once the Frigate process exits
# if this is running via s6, sigterm pid 1 os.kill(os.getpid(), signal.SIGTERM)
if proc.name() == "s6-svscan":
proc.terminate()
# otherwise, just try and exit frigate
else:
os.kill(os.getpid(), signal.SIGTERM)
class EventsPerSecond: class EventsPerSecond:

View File

@ -78,7 +78,7 @@ export default function AppBar() {
{showDialogWait ? ( {showDialogWait ? (
<Prompt <Prompt
title="Restart in progress" title="Restart in progress"
text="Please wait a few seconds for the restart to complete before reloading the page." text="This can take up to one minute, please wait before reloading the page."
/> />
) : null} ) : null}
</Fragment> </Fragment>