Created
October 19, 2021 16:50
-
-
Save ddxfish/2f9a29aa589c2143cacefa954e767c01 to your computer and use it in GitHub Desktop.
Mycroft Service Watchdog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# If you run mycroft in docker you may get Errno 111: Connection Refused | |
# On my container, a simple ./mycroft-stop and ./mycroft-start all fixes Error 111 | |
# This script checks your audio.log for Error 111 and will restart the mycroft service if it occurs | |
# put the script in your container, then edit /opt/mycroft/startup.sh | |
# Add your background watchdog script after mycroft starts in startup.sh, like: /opt/mycroft/./watchdog.sh & | |
while true | |
do | |
thetime=`date +%s` | |
echo watchdogtest $thetime | tee -a /var/log/mycroft/audio.log | |
sleep 20 | |
oneelevens=`cat /var/log/mycroft/audio.log | sed -n "/$thetime/,$p" | grep -c "Errno 111"` | |
echo "Watchdog: checking now" | tee -a /var/log/mycroft/audio.log | |
if [[ $oneelevens -gt 0 ]]; then | |
cd /opt/mycroft | |
./mycroft-stop | |
sleep 10 | |
./mycroft-start all | |
echo "Watchdog: mycroft restart attempt finished $oneelevens" | tee -a /var/log/mycroft/audio.log | |
else | |
echo "Watchdog: mycroft was found without errors $oneelevens" | tee -a /var/log/mycroft/audio.log | |
fi | |
sleep 90 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment