forked from blakeblackshear/frigate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add healthcheck for go2rtc service (blakeblackshear#5545)
* Upgrade s6-overlay from 3.1.3.0 to 3.1.4.0 * Add go2rtc healthcheck service Also don't make go2rtc exits cause the container to fail. * Reword healthcheck message Co-authored-by: Nicolas Mowen <[email protected]> * Add timeout to go2rtc healthcheck * Update healthcheck message Co-authored-by: Nicolas Mowen <[email protected]> * Give additional time for go2rtc start/restart * Fix typo * Avoid creating go2rtc config multiple times * Fix healthcheck not starting * Fix sleep * Fix more hidden logs * Decrease time window and use curl's timeout flag --------- Co-authored-by: Nicolas Mowen <[email protected]>
- Loading branch information
Showing
17 changed files
with
82 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
12 changes: 12 additions & 0 deletions
12
docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/finish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
# Logs should be sent to stdout so that s6 can collect them | ||
|
||
readonly exit_code_service="${1}" | ||
readonly exit_code_signal="${2}" | ||
readonly service="go2rtc-healthcheck" | ||
|
||
echo "[INFO] The ${service} service exited with code ${exit_code_service} (by signal ${exit_code_signal})" |
1 change: 1 addition & 0 deletions
1
docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/producer-for
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
go2rtc-log |
22 changes: 22 additions & 0 deletions
22
docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
# Start the go2rtc-healthcheck service | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
# Logs should be sent to stdout so that s6 can collect them | ||
|
||
# Give some additional time for go2rtc to start before start pinging | ||
sleep 10s | ||
echo "[INFO] Starting go2rtc healthcheck service..." | ||
|
||
while sleep 30s; do | ||
# Check if the service is running | ||
if ! curl --connect-timeout 10 --fail --silent --show-error --output /dev/null https://127.0.0.1:1984/api/streams 2>&1; then | ||
echo "[ERROR] The go2rtc service is not responding to ping, restarting..." | ||
# We can also use -r instead of -t to send kill signal rather than term | ||
s6-svc -t /var/run/service/go2rtc 2>&1 | ||
# Give some additional time to go2rtc to restart before start pinging again | ||
sleep 10s | ||
fi | ||
done |
1 change: 1 addition & 0 deletions
1
docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/timeout-kill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
longrun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
go2rtc | ||
go2rtc-healthcheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,12 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
# Take down the S6 supervision tree when the service exits | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
declare exit_code_container | ||
exit_code_container=$(cat /run/s6-linux-init-container-results/exitcode) | ||
readonly exit_code_container | ||
# Logs should be sent to stdout so that s6 can collect them | ||
|
||
readonly exit_code_service="${1}" | ||
readonly exit_code_signal="${2}" | ||
readonly service="go2rtc" | ||
|
||
echo "Service ${service} exited with code ${exit_code_service} (by signal ${exit_code_signal})" >&2 | ||
|
||
if [[ "${exit_code_service}" -eq 256 ]]; then | ||
if [[ "${exit_code_container}" -eq 0 ]]; then | ||
echo $((128 + exit_code_signal)) > /run/s6-linux-init-container-results/exitcode | ||
fi | ||
elif [[ "${exit_code_service}" -ne 0 ]]; then | ||
if [[ "${exit_code_container}" -eq 0 ]]; then | ||
echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode | ||
fi | ||
else | ||
# 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 | ||
|
||
exec /run/s6/basedir/bin/halt | ||
echo "[INFO] The ${service} service exited with code ${exit_code_service} (by signal ${exit_code_signal})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters