Skip to content

Instantly share code, notes, and snippets.

@qixtand
Created November 8, 2013 00:59
Show Gist options
  • Save qixtand/7364575 to your computer and use it in GitHub Desktop.
Save qixtand/7364575 to your computer and use it in GitHub Desktop.
A wrapper script to invoke the newrelic_resque_agent and capture it's PID for monit monitoring. Adapted from example 7.3.2 from http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_03.html.
#!/bin/bash
LOGFILE=/var/log/newrelic/newrelic-resque-agent.log
PIDFILE=/var/run/newrelic-resque-agent.pid
CONFIGFILE=/etc/newrelic/newrelic_resque_agent.yml
case $1 in
start)
exec 2>&1 /usr/bin/newrelic_resque_agent --config $CONFIGFILE run 1> $LOGFILE &
echo $! > $PIDFILE
;;
stop)
if [ -a $PIDFILE ]; then
kill `cat $PIDFILE`
rm -f $PIDFILE
fi
;;
*)
echo "usage: {start|stop}"
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment