Created
November 10, 2011 13:51
-
-
Save Zhengquan/1354892 to your computer and use it in GitHub Desktop.
A script to start unicorn at system boots
This file contains 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 | |
# File: /etc/init.d/unicorn | |
prog="unicorn" | |
PATH=/usr/local/rvm/gems/ruby-1.9.2-p290/bin:/usr/local/rvm/gems/ruby-1.9.2-p290@global/bin:/usr/local/rvm/rubies/ruby-1.9.2-p290/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games | |
DAEMON=`which unicorn_rails` | |
CONFIG_FILE=/var/www/magic/config/unicorn.rb | |
DAEMON_ARGS="$CONFIG_FILE" | |
APP_ROOT="/var/www/magic" | |
PID_FILE="$APP_ROOT/tmp/pids/unicorn.pid" | |
startcmd () { | |
echo $"Starting $prog:" | |
cd $APP_ROOT 2>/dev/null 1>&2 | |
$DAEMON -c $DAEMON_ARGS -E production -D | |
cd - 2>/dev/null 1>&2 | |
} | |
stopcmd () { | |
echo $"Stopping $prog:" | |
kill -QUIT `cat $PID_FILE` | |
} | |
case "$1" in | |
'start') | |
startcmd | |
;; | |
'stop') | |
stopcmd | |
;; | |
'restart') | |
stopcmd | |
sleep 1 | |
startcmd | |
;; | |
*) | |
echo "Usage: $0 { start | stop | restart }" | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment