Last active
June 10, 2016 11:56
-
-
Save furu/7fd69194640211826f14181ddd32a757 to your computer and use it in GitHub Desktop.
sinatra アプリケーションを unicorn で動かすときの unicorn の init スクリプト
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 | |
# chkconfig: 345 60 40 | |
# description: unicorn application server | |
# processname: unicorn | |
USER="ec2-user" | |
APP_ENV="production" | |
APP_ROOT="/home/ec2-user/www/foo/current" | |
UNICORN_CONF_FILE="$APP_ROOT/config/unicorn.rb" | |
PID="$APP_ROOT/tmp/pids/unicorn.pid" | |
BUNDLE="/usr/local/bin/bundle" | |
cd $APP_ROOT || exit 1 | |
start() { | |
su - $USER -c "cd $APP_ROOT && \ | |
SINATRA_ENV=$APP_ENV RAILS_ENV=$APP_ENV \ | |
$BUNDLE exec unicorn -c $UNICORN_CONF_FILE -E deployment -D" | |
} | |
sig() { | |
test -s $PID && kill -$1 `cat $PID` | |
} | |
case "$1" in | |
start) | |
sig 0 && echo >&2 "Already running" && exit 0 | |
$1 | |
;; | |
stop) | |
sig QUIT && exit 0 | |
echo >&2 "Not running" | |
;; | |
force-stop) | |
sig TERM && exit 0 | |
echo >&2 "Not running" | |
;; | |
status) | |
sig 0 && echo >&2 "unicorn is running" && exit 0 | |
echo >&2 "unicorn is not running" | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|force-stop|status}" | |
exit 2 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
参考