Skip to content

Commit

Permalink
updated HEALTHCHECK parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
kx1t committed Oct 23, 2023
1 parent ee5acb6 commit 90c9bda
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ RUN set -x && \
echo "alias dir=\"ls -alsv\"" >> /root/.bashrc && \
echo "alias nano=\"nano -l\"" >> /root/.bashrc

HEALTHCHECK --interval=30m --timeout=30s --start-period=60s CMD /scripts/healthcheck.sh
HEALTHCHECK --interval=300s --timeout=30s --start-period=300s --start-interval=30s --retries=1 CMD /scripts/healthcheck.sh
#
# No need for SHELL and ENTRYPOINT as those are inherited from the base image
#
11 changes: 8 additions & 3 deletions rootfs/etc/s6-overlay/scripts/radar1090
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,15 @@ fi
beast_host="${BEASTHOST:-ultrafeeder}"
if ! valid_ip "$beast_host"; then
beast_host="$(dig "$beast_host" | awk '{if ($1 == "'"$beast_host"'.") print $5}')"
# If it fails, print error message and loop trying every 30 secs
if [[ -z "$beast_host" ]]; then
"${s6wrap[@]}" --args echo "FATAL: BEASTHOST (\"$BEASTHOST\") must be a resolvable domain/hostname or an IP address. Halting operation."
exec sleep infinity
fi
while [[ -z "$beast_host" ]]; do
"${s6wrap[@]}" --args echo "WARNING: BEASTHOST (\"${BEASTHOST:-ultrafeeder}\") cannot be resolved. Make sure that \"${BEASTHOST:-ultrafeeder}\" is running or check your BEASTHOST parameter setting. Trying again in 30 seconds."
sleep 30
beast_host="$(dig "$beast_host" | awk '{if ($1 == "'"$beast_host"'.") print $5}')"
done
fi
chk_enabled "$VERBOSE" && "${s6wrap[@]}" --args echo "BEASTHOST (\"${BEASTHOST:-ultrafeeder}\") successfully resolved to $beast_host" || true
fi

RADAR_BIN=(/usr/sbin/radar)
Expand Down
2 changes: 1 addition & 1 deletion rootfs/scripts/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ touch "$HEALTHFILE"

read -r healthfailures < "$HEALTHFILE"

if [[ -n "$healthfailures" ]] && (( healthfailures > FAILURES_TO_GO_UNHEALTHY )); then
if [[ -n "$healthfailures" ]] && (( healthfailures >= FAILURES_TO_GO_UNHEALTHY )); then
"${s6wrap[@]}" --args echo "UNHEALTHY: No data is flowing to ${RADARSERVER:-adsb-in.1090mhz.uk}:${RADARPORT:-2227}/${TRANSPORT_PROTOCOL:-udp} - failure count since last successful measurement is $healthfailures"
exit 1
else
Expand Down

0 comments on commit 90c9bda

Please sign in to comment.