Refactor watchdog logic to implement host-based delay in watchdog_run function

develop
Dominik Dzienia 5 days ago
parent 8e0be92834
commit 1c445a43b4

@ -200,6 +200,6 @@ parse_commandline_args() {
if [ "$WATCHDOGMODE" = "true" ]; then
startup_version
startup_debug
watchdog_check
watchdog_run
fi
}

@ -160,6 +160,15 @@ get_watchdog_status() {
}
watchdog_run() {
local host_hash
host_hash=$(printf '%s' "$(hostname)" | md5sum | awk '{print $1}' | cut -c1-8 | xargs printf '%d' 16 16)
local offset=$(( host_hash % 300 ))
echo "Watchdog delay: sleeping ${offset}s (host-based offset)"
sleep "$offset"
watchdog_check
}
watchdog_check() {
echo "---------------------------"
echo " Nightscout Watchdog mode"

Loading…
Cancel
Save