Skip to content

Commit

Permalink
add watchdog
Browse files Browse the repository at this point in the history
possible workaround for
sdr-enthusiasts#168
  • Loading branch information
wiedehopf committed Oct 20, 2024
1 parent 053a5b2 commit 2567503
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
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
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 2567503

Please sign in to comment.