Skip to content

Instantly share code, notes, and snippets.

@foyo23
Forked from tomkersten/bash.bashrc
Created April 11, 2012 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foyo23/2360035 to your computer and use it in GitHub Desktop.
Save foyo23/2360035 to your computer and use it in GitHub Desktop.
unicorn startup script for rails app
#! /bin/sh
# File: /etc/init.d/unicorn
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the unicorn web server
# Description: starts unicorn
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
#DAEMON=/usr/local/rvm/gems/ree-1.8.7-2010.02/bin/unicorn
#DAEMON=/usr/local/rvm/gems/ruby-1.9.3-p125/bin/unicorn
#DAEMON=/usr/local/rvm/gems/ruby-1.9.3-p125/bin/unicorn_rails
DAEMON="bundle exec /usr/local/rvm/gems/ruby-1.9.3-p125/bin/unicorn_rails"
DAEMON_OPTS="-c /home/deployer/apps/yfplatform/current/config/unicorn.rb -E production -D"
NAME=unicorn
DESC="Unicorn app for yfplatform"
APP_DIR=/home/deployer/apps/yfplatform/current/
#PID=/home/deployer/apps/yfplatform/pids/unicorn.pid
PID=/tmp/unicorn.yfplatform.pid
case "$1" in
start)
echo -n "Starting $DESC: "
cd $APP_DIR
$DAEMON $DAEMON_OPTS
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
kill -QUIT `cat $PID`
echo "$NAME."
;;
restart)
echo -n "Restarting $DESC: "
kill -QUIT `cat $PID`
sleep 1
cd $APP_DIR
$DAEMON $DAEMON_OPTS
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
kill -HUP `cat $PID`
echo "$NAME."
;;
*)
echo "Usage: $NAME {start|stop|restart|reload}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment