Skip to content

Instantly share code, notes, and snippets.

@ekilah
Created July 31, 2016 19:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekilah/220f87a5975bb25d2be8e4fa20aa6a13 to your computer and use it in GitHub Desktop.
Save ekilah/220f87a5975bb25d2be8e4fa20aa6a13 to your computer and use it in GitHub Desktop.
monit wrapper script to start a non-daemonized process like lita
check process lita with pidfile /usr/local/var/run/lita.pid
start program = "/full/path/to/litadaemonscript/litadaemon start"
stop program = "/full/path/to/litadaemonscript/litadaemon stop"
#!/usr/bin/env bash
PIDFILE=/usr/local/var/run/lita.pid
LOGFILE=/usr/local/var/log/lita.log
LITA_PROJECT_DIR=/full/path/to/projectdir/
case $1 in
start)
cd ${LITA_PROJECT_DIR}
rm ${LOGFILE} # optional, remove old logfile
exec lita start >> ${LOGFILE} 2>&1 &
echo $! > ${PIDFILE} # save spawned backround process' PID to PIDFILE
echo "lita started with PID:"
cat ${PIDFILE};;
stop)
kill `cat ${PIDFILE}`
rm ${PIDFILE};;
*)
echo "usage: $0 {start|stop}" ;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment