Skip to content

Instantly share code, notes, and snippets.

@bageljp
Created July 21, 2013 09:35
Show Gist options
  • Select an option

  • Save bageljp/6048066 to your computer and use it in GitHub Desktop.

Select an option

Save bageljp/6048066 to your computer and use it in GitHub Desktop.
unicorn init script with rbenv and bundler.
#!/bin/sh
#
# unicorn
#
# chkconfig: - 80 20
# description: unicorn
# processname: unicorn
# config: /usr/local/redmine/config/unicorn.rb
# pidfile: /usr/local/redmine/tmp/pids/.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
prog="unicorn"
RAILS_ROOT="/usr/local/redmine"
lockfile="/var/lock/subsys/unicorn"
pidfile="${RAILS_ROOT}/tmp/pids/unicorn.pid"
CONF_FILE="${RAILS_ROOT}/config/unicorn.rb"
CMD_BUNDLE="/root/.rbenv/shims/bundle"
PATH="/usr/local/rbenv/bin:${PATH}"
#eval "$(rbenv init -)"
start() {
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
cd ${RAILS_ROOT}
${CMD_BUNDLE} exec unicorn_rails -c ${CONF_FILE} -E production -D --path /redmine
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
case "$1" in
start)
$1
;;
stop)
$1
;;
restart)
$1
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 2
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment