docker: add an healthcheck for ipinfo updater container

We could add a dependency of the orchestrator on it, but it may break
some setups. We'll see later.
This commit is contained in:
Vincent Bernat
2025-05-08 17:09:32 +02:00
parent f153de41af
commit bd0e0f25db
2 changed files with 8 additions and 0 deletions

View File

@@ -10,3 +10,8 @@ services:
- UPDATE_FREQUENCY=48h - UPDATE_FREQUENCY=48h
volumes: volumes:
- akvorado-geoip:/data - akvorado-geoip:/data
healthcheck:
interval: 10s
timeout: 10s
retries: 0
test: ["CMD", "test", "-f", "/tmp/healthy"]

View File

@@ -3,6 +3,7 @@
trap exit TERM trap exit TERM
while true; do while true; do
ok=1
for DATABASE in ${IPINFO_DATABASES}; do for DATABASE in ${IPINFO_DATABASES}; do
if [ -f ${DATABASE}.mmdb ]; then if [ -f ${DATABASE}.mmdb ]; then
# Is it up-to-date? # Is it up-to-date?
@@ -29,10 +30,12 @@ while true; do
*) *)
echo "Failed to download ${DATABASE}.mmdb database (HTTP error $RESPONSE)." echo "Failed to download ${DATABASE}.mmdb database (HTTP error $RESPONSE)."
rm "${DATABASE}.mmdb.new" 2> /dev/null rm "${DATABASE}.mmdb.new" 2> /dev/null
ok=0
;; ;;
esac esac
done done
[ $ok -eq 1 ] && touch /tmp/healthy
sleep "$UPDATE_FREQUENCY" & sleep "$UPDATE_FREQUENCY" &
wait $! wait $!
done done