add watchdog service

This commit is contained in:
Daniel Barlow
2023-09-02 17:28:40 +01:00
parent 6805e0090d
commit 83092b7b73
5 changed files with 66 additions and 40 deletions

23
modules/watchdog/gaspode.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/sh
deadline=$(expr $(date +%s) + ${HEADSTART})
services=$@
echo started feeding the dog
exec 3> ${WATCHDOG-/dev/watchdog}
healthy(){
test $(date +%s) -le $deadline && return 0
for i in $services; do
if test "$(s6-svstat -o up /run/service/$i)" != "true" ; then
echo "service $i is down"
return 1
fi
done
}
while healthy ;do
sleep 10
echo >&3
done
echo "stopped feeding the dog"
sleep 6000 # don't want s6-rc to restart