Skip to content

Instantly share code, notes, and snippets.

@igaiga igaiga/unicorn_tdiary
Last active Jan 1, 2016

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.