Last active
January 1, 2016 16:08
-
-
Save igaiga/8168352 to your computer and use it in GitHub Desktop.
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 | |
# refered to http://shoprev.hatenablog.com/entry/2013/07/15/172404 . thanks! | |
NAME="Unicorn for tdiary" | |
ROOT_DIR="/home/igarashi/var/tdiary/tdiary-core" | |
PID="${ROOT_DIR}/unicorn.pid" | |
CONF="${ROOT_DIR}/unicorn.conf" | |
BUNDLE_DIR="/home/igarashi/.rbenv/shims/" | |
CMD="${BUNDLE_DIR}/bundle exec unicorn -c ${CONF} -D" | |
start() | |
{ | |
if [ -e $PID ]; then | |
echo "$NAME already started" | |
exit 1 | |
fi | |
echo "start $NAME" | |
cd $ROOT_DIR | |
$CMD | |
} | |
stop() | |
{ | |
if [ ! -e $PID ]; then | |
echo "$NAME not started" | |
exit 1 | |
fi | |
echo "stop $NAME" | |
kill -QUIT `cat ${PID}` | |
} | |
force_stop() | |
{ | |
if [ ! -e $PID ]; then | |
echo "$NAME not started" | |
exit 1 | |
fi | |
echo "stop $NAME" | |
kill -INT `cat ${PID}` | |
} | |
reload() | |
{ | |
if [ ! -e $PID ]; then | |
echo "$NAME not started" | |
start | |
exit 0 | |
fi | |
echo "reload $NAME" | |
kill -HUP `cat ${PID}` | |
} | |
restart() | |
{ | |
stop | |
# Unicorn が停止し切らない内に起動しようとしないように | |
sleep 3 | |
start | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
force-stop) | |
force_stop | |
;; | |
reload) | |
reload | |
;; | |
restart) | |
restart | |
;; | |
*) | |
echo "Syntax Error: release [start|stop|force-stop|reload|restart]" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment