RedBot Discord bot failsafe bash script with monit
1 min read

RedBot Discord bot failsafe bash script with monit

#!/bin/bash PIDFILE=/var/run/redbot.pid case $1 in start) echo $! > ${PIDFILE} cd "$(dirname "$0")" su - redbot -c "cd /home/redbot/Red-DiscordBot && python3.5 ./red.py &" read -rsp $'Press enter to continue...\n' ;; stop) kill `cat ${PIDFILE}` rm ${PIDFILE} ;; *) echo "usage: redbot {start|stop}" ;; esac exit 0

Monit conf.d file

check process redbot with pidfile /var/run/redbot.pid start = "/home/redbot/Red-DiscordBot/start_red.sh start" stop = "/home/redbot/Red-DiscordBot/start_red.sh stop"