diff --git a/Dockerfile b/Dockerfile index 72840f5..03708af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 # diff --git a/rootfs/etc/s6-overlay/scripts/radar1090 b/rootfs/etc/s6-overlay/scripts/radar1090 index c5ce53b..e11566f 100755 --- a/rootfs/etc/s6-overlay/scripts/radar1090 +++ b/rootfs/etc/s6-overlay/scripts/radar1090 @@ -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) diff --git a/rootfs/scripts/healthcheck.sh b/rootfs/scripts/healthcheck.sh index 59a2430..02f342b 100755 --- a/rootfs/scripts/healthcheck.sh +++ b/rootfs/scripts/healthcheck.sh @@ -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