Skip to content

Commit

Permalink
message monitor: only print stale message and (potentially) restart i…
Browse files Browse the repository at this point in the history
…f we're within the adjustment timeframe (#92)

Co-authored-by: kx1t <[email protected]>
  • Loading branch information
fredclausen and kx1t authored Mar 18, 2024
1 parent d1076f0 commit bf8603e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions rootfs/etc/s6-overlay/scripts/message-monitor
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)"
Expand Down

1 comment on commit bf8603e

@kx1t
Copy link
Member

@kx1t kx1t commented on bf8603e Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in #104

Please sign in to comment.