Skip to content

NVR with realtime local object detection for IP cameras

Avoid unhealthy container when Frigate is stopping (#18021)

Felipe Santos52d94231c7cf
diff --git a/docker/main/Dockerfile b/docker/main/Dockerfile
index a712508136..f58e3d5a9a 100644
--- a/docker/main/Dockerfile
+++ b/docker/main/Dockerfile
@@ -260,7 +260,7 @@ ENTRYPOINT ["/init"]
CMD []
HEALTHCHECK --start-period=300s --start-interval=5s --interval=15s --timeout=5s --retries=3 \
- CMD curl --fail --silent --show-error http://127.0.0.1:5000/api/version || exit 1
+ CMD test -f /dev/shm/.frigate-is-stopping && exit 0; curl --fail --silent --show-error http://127.0.0.1:5000/api/version || exit 1
# Frigate deps with Node.js and NPM for devcontainer
FROM deps AS devcontainer
diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/finish b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/finish
index 75869b5e76..27a02843cb 100755
--- a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/finish
+++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/finish
@@ -25,4 +25,7 @@ elif [[ "${exit_code_service}" -ne 0 ]]; then
fi
fi
+# used by the docker healthcheck
+touch /dev/shm/.frigate-is-stopping
+
exec /run/s6/basedir/bin/halt
diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/prepare/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/prepare/run
index 0460cd2b48..27b1d6326e 100755
--- a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/prepare/run
+++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/prepare/run
@@ -138,5 +138,9 @@ function migrate_db_from_media_to_config() {
fi
}
+# remove leftover from last run, not normally needed, but just in case
+# used by the docker healthcheck
+rm -f /dev/shm/.frigate-is-stopping
+
migrate_addon_config_dir
migrate_db_from_media_to_config