From bf8603ef620fb7249abfdc8e9bcb1b659084350d Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 18 Mar 2024 09:01:43 -0600 Subject: [PATCH] message monitor: only print stale message and (potentially) restart if we're within the adjustment timeframe (#92) Co-authored-by: kx1t <15090643+kx1t@users.noreply.github.com> --- rootfs/etc/s6-overlay/scripts/message-monitor | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/message-monitor b/rootfs/etc/s6-overlay/scripts/message-monitor index 3992e17..1efd2df 100755 --- a/rootfs/etc/s6-overlay/scripts/message-monitor +++ b/rootfs/etc/s6-overlay/scripts/message-monitor @@ -4,6 +4,7 @@ source /scripts/common mkdir -p /run/stats s6wrap=(s6wrap --quiet --prepend="$(basename "$0")" --timestamps --args) +READSB_AUTOGAIN_ADJUSTMENT_TIMEFRAME="${DUMP978_AUTOGAIN_ADJUSTMENT_TIMEFRAME:-${READSB_AUTOGAIN_ADJUSTMENT_TIMEFRAME:-0800-1800}}" while : do @@ -34,10 +35,14 @@ do "${s6wrap[@]}" echo "[STARTING] Receiver starting: No messages have been received as the container is still starting" new_msg_count=0 elif (( new_msg_count == old_msg_count )); then - "${s6wrap[@]}" echo "[WARNING] Receiver appears stale: No messages received since last run of the Messages Monitor ($secs_since_last_check secs ago)" - if chk_enabled "$DUMP978_MSG_MONITOR_RESTART_WHEN_STALE"; then - "${s6wrap[@]}" echo "[WARNING] Restarting the dump978 service..." - s6-svc -r /run/service/dump978 2>/dev/null || true + # only print and restart if we're within the adjustment timeframe + if (( $(date +%s) < $(date -d "${READSB_AUTOGAIN_ADJUSTMENT_TIMEFRAME%%-*} today" +%s) )); then + "${s6wrap[@]}" echo "[WARNING] Receiver appears stale: No messages received since last run of the Messages Monitor ($secs_since_last_check secs ago)" + + if chk_enabled "$DUMP978_MSG_MONITOR_RESTART_WHEN_STALE"; then + "${s6wrap[@]}" echo "[WARNING] Restarting the dump978 service..." + s6-svc -r /run/service/dump978 2>/dev/null || true + fi fi elif (( new_msg_count > old_msg_count )); then "${s6wrap[@]}" echo "[INFO] Receiver is OK: $(( new_msg_count - old_msg_count )) messages received since last run of the Messages Monitor ($secs_since_last_check secs ago)"