Skip to content

Instantly share code, notes, and snippets.

@ismriv
Created December 30, 2012 21:33
Show Gist options
  • Select an option

  • Save ismriv/4415357 to your computer and use it in GitHub Desktop.

Select an option

Save ismriv/4415357 to your computer and use it in GitHub Desktop.
Init script for god service (using RVM)
#!/bin/bash
### BEGIN INIT INFO
# Provides: god
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: God
### END INIT INFO
NAME=god
DESC=god
# DEAMON=/usr/local/bin/god
DEAMON=/usr/local/rvm/gems/ruby-1.9.3-p327/bin/god
PID=/var/run/god.pid
LOG=/var/log/god.log
# GOD_CONFIG=/etc/god/conf.god
GOD_CONFIG=/opt/www/aypventas/latest/config/thin.god
set -e
# Make sure the binary and the config file are present before proceeding
test -x $DEAMON || exit 0
. /lib/lsb/init-functions
# required to load RVM env: http://stackoverflow.com/questions/12127603/usr-bin-env-ruby-noexec-wrapper-fails-with-no-file-or-directory
source /usr/local/rvm/environments/ruby-1.9.3-p327
RETVAL=0
case "$1" in
start)
echo -n "Starting $DESC: "
$DEAMON -c $GOD_CONFIG -P $PID -l $LOG
RETVAL=$?
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
kill `cat $PID`
RETVAL=$?
echo "$NAME."
;;
restart)
echo -n "Restarting $DESC: "
kill `cat $PID`
$DEAMON -c $GOD_CONFIG -P $PID -l $LOG
RETVAL=$?
echo "$NAME."
;;
status)
$DEAMON status
RETVAL=$?
;;
*)
echo "Usage: god {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