Created
February 14, 2012 13:26
-
-
Save cr0t/1826746 to your computer and use it in GitHub Desktop.
unicorn init script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# we assume that we use system wide rvm installation (in /usr/local/rvm) | |
# and our application is deployed to /var/www/tld.appname directory | |
RVM_ENV="ruby-1.9.3-p0@gemset" | |
APP_DIR="tld.appname" | |
# load rvm | |
source /usr/local/rvm/environments/$RVM_ENV | |
APP_PATH=/var/www/$APP_DIR | |
CONFIG=$APP_PATH/current/config/unicorn.rb | |
RAILS_ENV=production | |
UNICORN_PID=$APP_PATH/shared/pids/unicorn.pid | |
start() | |
{ | |
cd $APP_PATH/current && bundle exec unicorn -c $CONFIG -E $RAILS_ENV -D | |
} | |
stop() | |
{ | |
cd $APP_PATH && if [ -f $UNICORN_PID ] && [ -e /proc/$(cat $UNICORN_PID) ]; then kill -QUIT `cat $UNICORN_PID`; fi | |
} | |
restart() | |
{ | |
if [ -f $UNICORN_PID ] && [ -e /proc/$(cat $UNICORN_PID) ]; then kill -USR2 `cat $UNICORN_PID`; else cd $APP_PATH/current && bundle exec unicorn -c $CONFIG -E $RAILS_ENV -D; fi | |
} | |
case "$1" in | |
start) start;; | |
stop) stop;; | |
restart) restart;; | |
*) echo "Unknown parameter '$1'" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment