diff --git a/README.md b/README.md index 8744eb8..3202ce6 100644 --- a/README.md +++ b/README.md @@ -278,7 +278,7 @@ You should now be feeding ADSB-ES & UAT to the "new" aggregators, FlightAware, a | `LAT` | Latitude of your receiver. Only required if you want range statistics for InfluxDB, Prometheus, or tar1090/ultrafeeder graphs. | Unset | | `LON` | Longitude of your receiver. Only required if you want range statistics for InfluxDB, Prometheus, or tar1090/ultrafeeder graphs. | Unset | | `DUMP978_MSG_MONITOR_INTERVAL` | Interval between runs of the Message Monitor that checks if new messages are received. Format of value is anything that is accepted by the Linux `sleep` command | Unset (30 minutes) | -| `DUMP978_MSG_MONITOR_RESTART_WHEN_STALE` | If set to `true`/`on`/`yes`/`1`, the receiver process is restarted when no messages are received during the monitoring interval | Unset (`false`) | +| `DUMP978_MSG_MONITOR_RESTART_WHEN_STALE` | If set to `true`/`on`/`yes`/`1`, the receiver process is restarted when no messages are received during the monitoring interval | `true` | ### `dump978-fa` General Options diff --git a/rootfs/etc/s6-overlay/scripts/message-monitor b/rootfs/etc/s6-overlay/scripts/message-monitor index 1efd2df..6bbae59 100755 --- a/rootfs/etc/s6-overlay/scripts/message-monitor +++ b/rootfs/etc/s6-overlay/scripts/message-monitor @@ -4,8 +4,13 @@ source /scripts/common mkdir -p /run/stats s6wrap=(s6wrap --quiet --prepend="$(basename "$0")" --timestamps --args) + +# Adjustment Timeframe is the same as used for AutoGain, with a default of 0800-1800 "container time" if omitted READSB_AUTOGAIN_ADJUSTMENT_TIMEFRAME="${DUMP978_AUTOGAIN_ADJUSTMENT_TIMEFRAME:-${READSB_AUTOGAIN_ADJUSTMENT_TIMEFRAME:-0800-1800}}" +# Restart When Stale is default-TRUE. This is acceptable - worst case, we'd restart the dump978 s6 service once every 30 minutes +DUMP978_MSG_MONITOR_RESTART_WHEN_STALE="${DUMP978_MSG_MONITOR_RESTART_WHEN_STALE:-true}" + while : do # Make sure we're receiving messages from the SDR @@ -35,14 +40,16 @@ 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 - # 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)" - + "${s6wrap[@]}" echo "[WARNING] Receiver appears stale: No messages received since last run of the Messages Monitor ($secs_since_last_check secs ago)" + # only restart if we're within the adjustment timeframe + if (( $(date +%s) >= $(date -d "${READSB_AUTOGAIN_ADJUSTMENT_TIMEFRAME%%-*} today" +%s) )) \ + && (( $(date +%s) <= $(date -d "${READSB_AUTOGAIN_ADJUSTMENT_TIMEFRAME##*-} today" +%s) )); then 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 + else + "${s6wrap[@]}" echo " No action is taken since we're outside the Adjustment Timeframe of ${READSB_AUTOGAIN_ADJUSTMENT_TIMEFRAME}" 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)"