@@ -5,8 +5,6 @@ set -euo pipefail
55TIMEOUT=" ${TIMEOUT:- 300} "
66INTERVAL=" ${INTERVAL:- 5} "
77
8- # --- Phase 1: Startup health wait ---
9-
108# Read container IDs into array, one per line, then put it into the CONTAINERS var
119mapfile -t CONTAINERS < <( podman-compose ps -q)
1210TOTAL=${# CONTAINERS[@]}
@@ -46,32 +44,3 @@ while true; do
4644done
4745
4846systemd-notify --ready --status=" All ${TOTAL} containers healthy"
49-
50- # --- Phase 2: Watchdog loop ---
51-
52- # WATCHDOG_USEC is set automatically by systemd from WatchdogSec= (in microseconds).
53- # We convert to seconds and halve it so we actually check in well before the deadline.
54- # We also hardcode on purpose the minimal healcheck interval to 5 seconds.
55- WATCHDOG_USEC=" ${WATCHDOG_USEC:- 60000000} "
56- WATCHDOG_SEC=$(( WATCHDOG_USEC / 1000000 / 2 ))
57- [ " $WATCHDOG_SEC " -lt 5 ] && WATCHDOG_SEC=5
58-
59- while true ; do
60- sleep " $WATCHDOG_SEC "
61-
62- for c in " ${CONTAINERS[@]} " ; do
63- STATE=$( podman inspect --format " {{.State.Status}}" " $c " 2> /dev/null || true)
64- if [ " $STATE " != " running" ]; then
65- echo " Container $c is no longer running (state: ${STATE:- gone} )"
66- exit 1
67- fi
68-
69- HEALTH=$( podman inspect --format " {{.State.Health.Status}}" " $c " 2> /dev/null || true)
70- if [ " $HEALTH " = " unhealthy" ]; then
71- echo " Container $c became unhealthy"
72- exit 1
73- fi
74- done
75-
76- systemd-notify WATCHDOG=1 --status=" Watchdog: ${TOTAL} containers healthy"
77- done
0 commit comments