Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix message monitor #104

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Copy link
Member

Choose a reason for hiding this comment

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

Is this change reflected in the Dockerfile? I suspect the default already is true, but I’m not sure.

Also, I’m not sure I’m a fan of making it the default behavior. It is going to cause a lot of log spam in this container, as well as any other container that also plugs in and grabs UAT data if it is restarting with some frequency. Basically, what I think I’m ultimately saying is that the odds there is an actual reception issue are really low, and restarting the decoder isn’t really beneficial. That said, if the feeling among everyone is this is the better way, then I’m fine with it.


### `dump978-fa` General Options

Expand Down
15 changes: 11 additions & 4 deletions rootfs/etc/s6-overlay/scripts/message-monitor
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)"
Expand Down