Mycroft Watchdog Script

From ETCwiki
Jump to navigationJump to search

If you run Mycroft in Docker, you may have seen a ton of errors when it tries to connect to the Messagebus. I get Errno 111 Connection Refused on Mycroft a ton. In my situation, all I needed to do was /opt/mycroft/./ and then /opt/mycroft/./ all and things would start working again. If this is your case too, try this watchdog script inside your Mycroft container.

Add to /opt/mycroft/

source /opt/mycroft/.venv/bin/activate
/opt/mycroft/./ all
/opt/mycroft/./ &
tail -f /var/log/mycroft/*.log


# 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/ 
# Add your background watchdog script after mycroft starts in, like: /opt/mycroft/./ &
while true
        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
                sleep 10
                ./mycroft-start all
                echo "Watchdog: mycroft restart attempt finished $oneelevens" | tee -a /var/log/mycroft/audio.log
                echo "Watchdog: mycroft was found without errors $oneelevens" | tee -a /var/log/mycroft/audio.log
        sleep 90

External Links