mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 17:55:21 +03:00
Ensure oneshot runs
This commit is contained in:
parent
2915165bd5
commit
a61740d0ce
@ -198,7 +198,7 @@ EXPOSE 8555/tcp 8555/udp
|
||||
ENV S6_LOGGING_SCRIPT="T 1 n0 s10000000 T"
|
||||
|
||||
ENTRYPOINT ["/init"]
|
||||
CMD []
|
||||
CMD ["/etc/s6-overlay/validate_services.sh"]
|
||||
|
||||
# Frigate deps with Node.js and NPM for devcontainer
|
||||
FROM deps AS devcontainer
|
||||
|
||||
@ -91,3 +91,4 @@ rm -rf /var/lib/apt/lists/*
|
||||
curl -fsSL \
|
||||
"https://github.com/mikefarah/yq/releases/download/v4.30.8/yq_linux_$(dpkg --print-architecture)" \
|
||||
--output /usr/local/bin/yq
|
||||
chmod +x /usr/local/bin/yq
|
||||
|
||||
@ -1 +0,0 @@
|
||||
/etc/s6-overlay/s6-rc.d/frigate-prepare/finish
|
||||
@ -1,26 +0,0 @@
|
||||
#!/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
|
||||
readonly exit_code_service="${1}"
|
||||
readonly exit_code_signal="${2}"
|
||||
readonly service="frigate-prepare"
|
||||
|
||||
echo "[INFO] 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
|
||||
fi
|
||||
|
||||
exec /run/s6/basedir/bin/halt
|
||||
25
docker/rootfs/etc/s6-overlay/validate_services.sh
Executable file
25
docker/rootfs/etc/s6-overlay/validate_services.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/command/with-contenv bash
|
||||
# shellcheck shell=bash
|
||||
# Checks if all oneshot services executed succesfully
|
||||
# https://github.com/just-containers/s6-overlay/issues/513#issuecomment-1401399995
|
||||
|
||||
set -o errexit -o nounset -o pipefail
|
||||
|
||||
readonly wanted_services=(
|
||||
log-prepare
|
||||
frigate-prepare
|
||||
# go2rtc-prepare
|
||||
)
|
||||
|
||||
services=$(s6-rc -a list) # lists active/executed services, one per line
|
||||
readonly services
|
||||
|
||||
for wanted_service in "${wanted_services[@]}"; do
|
||||
if ! echo "${services}" | grep -qFx "${wanted_service}" ; then
|
||||
echo "[ERROR] Service '${wanted_service}' failed to execute" >&2
|
||||
echo 1 > /run/s6-linux-init-container-results/exitcode # to say the container failed
|
||||
exec /run/s6/basedir/bin/halt
|
||||
fi
|
||||
done
|
||||
|
||||
exec s6-pause # or exec into your real CMD if you have one
|
||||
Loading…
Reference in New Issue
Block a user