Skip to content

Instantly share code, notes, and snippets.

@quicksnap
Created January 25, 2013 08:00
Show Gist options
  • Save quicksnap/4632637 to your computer and use it in GitHub Desktop.
Save quicksnap/4632637 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# God
#
# chkconfig: 2345 85 15
# description: start, stop, restart God
#
# Also consider adding this line (kills god weekly) to your crontab (sudo crontab -e):
#
# # deicide is painless
# 0 1 * * 0 god quit; sleep 1; killall god; sleep 1; killall -9 god; sleep 1; /etc/init.d/god start
#
. /etc/rc.d/init.d/functions
RETVAL=0
prog="god"
CONF="/your/app/location/config.god"
PID_FILE="/var/run/god/god.pid" ; mkdir -p `dirname $PID_FILE`
LOG_FILE="/var/log/god/god.log" ; mkdir -p `dirname $LOG_FILE`
GOD="/usr/local/rvm/bin/bootup_god" # This may need to be created with `rvm wrapper` command
start()
{
echo -n $"Starting $prog: "
$GOD -c "$CONF" -P "$PID_FILE" -l "$LOG_FILE" && success || failure
RETVAL=$?
echo
}
stop()
{
echo -n $"Stopping $prog: "
kill `cat $PID_FILE` && success || failure
RETVAL=$?
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status -p $PID_FILE $prog
RETVAL=$?
;;
*)
echo "Usage: $prog {start|stop|restart|status}"
exit 1
;;
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment