Skip to content

Commit

Permalink
add watchdog / add minimal mode (#209)
Browse files Browse the repository at this point in the history
* add watchdog

possible workaround for
#168

* add PIAWARE_MINIMAL mode without maps
  • Loading branch information
wiedehopf authored Oct 20, 2024
1 parent 053a5b2 commit 036ef80
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ Use only with `RECEIVER_TYPE=relay`.
| `BEASTPORT` | a port number | Specify the TCP port number of the external BEAST protocol provider. | `30005` |
| `MLAT_RESULTS_BEASTHOST` | a hostname or IP | Specify an external host where MLAT results should be sent. | |
| `MLAT_RESULTS_BEASTPORT` | a port number | Specify the TCP port number where MLAT results should be sent. | `30104` |
| `PIAWARE_MINIMAL` | true or false | Minimal feed configuration without maps | `false` |

### Receiver Configuration (978MHz)

Expand Down
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/watchdog/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /etc/s6-overlay/scripts/watchdog
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/watchdog/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
18 changes: 15 additions & 3 deletions rootfs/etc/s6-overlay/scripts/01-piaware
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/command/with-contenv bash
# shellcheck shell=bash
# shellcheck shell=bash disable=SC1091,2154

source /scripts/common

# Remove existing piaware config
rm /etc/piaware.conf > /dev/null 2>&1 || true
Expand Down Expand Up @@ -54,7 +56,11 @@ piaware-config mlat-results "${MLAT_RESULTS:-yes}"

# If a BEASTHOST is specified
if [[ -n "$BEASTHOST" ]]; then
piaware-config receiver-type "relay"
if chk_enabled "${PIAWARE_MINIMAL}"; then
piaware-config receiver-type "other"
else
piaware-config receiver-type "relay"
fi
piaware-config receiver-host "$BEASTHOST"
piaware-config receiver-port "${BEASTPORT:-30005}"

Expand All @@ -79,10 +85,16 @@ elif [[ "$UAT_RECEIVER_TYPE" == "rtlsdr" ]]; then

fi

MLAT_RESULTS_STRING="beast,listen,30105 ext_basestation,listen,30106 "
if ! chk_enabled "${PIAWARE_MINIMAL}"; then
MLAT_RESULTS_STRING+="beast,connect,localhost:30104 "
fi

# If MLAT_RESULTS_BEAST_CONNECT is specified
if [[ -n "$MLAT_RESULTS_BEASTHOST" ]]; then
piaware-config mlat-results-format "beast,connect,localhost:30104 beast,listen,30105 ext_basestation,listen,30106 beast,connect,${MLAT_RESULTS_BEASTHOST}:${MLAT_RESULTS_BEASTPORT:-30104}"
MLAT_RESULTS_STRING+="beast,connect,${MLAT_RESULTS_BEASTHOST}:${MLAT_RESULTS_BEASTPORT:-30104} "
fi
piaware-config mlat-results-format "${MLAT_RESULTS_STRING}"

# Create log dir for piaware
mkdir -p /var/log/piaware
Expand Down
3 changes: 3 additions & 0 deletions rootfs/etc/s6-overlay/scripts/beast-splitter
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ source /scripts/common
if [[ -z "$BEASTHOST" ]]; then
stop_service
fi
if chk_enabled "${PIAWARE_MINIMAL}"; then
stop_service
fi

# Prepare beast-splitter command line
BEASTSPLITTER_BIN="/usr/local/bin/beast-splitter"
Expand Down
3 changes: 3 additions & 0 deletions rootfs/etc/s6-overlay/scripts/dump1090
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ fi
if [[ -z "$RUN_DUMP1090" ]]; then
stop_service
fi
if chk_enabled "${PIAWARE_MINIMAL}"; then
stop_service
fi

mkdir -p /run/dump1090-fa

Expand Down
3 changes: 3 additions & 0 deletions rootfs/etc/s6-overlay/scripts/skyaware978
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ fi
if [[ -z "$RUN_SKYAWARE978" ]]; then
stop_service
fi
if chk_enabled "${PIAWARE_MINIMAL}"; then
stop_service
fi

mkdir -p /run/skyaware978

Expand Down
22 changes: 22 additions & 0 deletions rootfs/etc/s6-overlay/scripts/watchdog
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/command/with-contenv bash
# shellcheck shell=bash disable=SC1091,2154

source /scripts/common

# checking every 60 seconds
sleep 60

# check if the current date is larger than the expiry field of the status json
if (( $(date +%s) * 1000 > $(grep -o -E -e '(expiry)" *: ([0-9]+)' /run/piaware/status.json | awk '{print $3}') )); then
# current date being larger means piaware is hanging, kill it
"${s6wrap[@]}" echo "piaware is not updating /run/piaware/status.json, sending SIGKILL"
pkill -9 piaware
fi


# make sure /var/log/piaware/current doesn't grow too large
if (( $(wc -l < /var/log/piaware/current) > 400 )); then
keep=$(tail -n200 /var/log/piaware/current)
truncate -s 0 /var/log/piaware/current
cat >> /var/log/piaware/current <<< "$keep"
fi

0 comments on commit 036ef80

Please sign in to comment.