I'm using Monit to monitor a system. I have a python file I wish to also monitor, I understand that I need to create a wrapper script as python does not generate pid files. I followed the instructions on this site, however I have been unable to get the script to start. I've never created a wrapper script before, so I think I have an error in my script. The log from monit says "Failed to start"
Monit rule
check process scraper with pidfile /var/run/scraper.pid
start = "/bin/scraper start"
stop = "/bin/scraper stop"
wrapper script
#!/bin/bash
PIDFILE=/var/run/scraper.pid
case $1 in
start)
echo $$ > ${PIDFILE};
source /home
exec python /home/scraper.py 2>/dev/null
;;
stop)
kill `cat ${PIDFILE}` ;;
*)
echo "usage: scraper {start|stop}" ;;
esac
exit 0