2014-07-04 03:45:20 -04:00
|
|
|
#!/bin/sh
|
2013-10-09 10:45:32 -04:00
|
|
|
|
|
|
|
cd $(dirname $0)/..
|
|
|
|
app_root=$(pwd)
|
|
|
|
|
|
|
|
unicorn_pidfile="$app_root/tmp/pids/unicorn.pid"
|
|
|
|
unicorn_config="$app_root/config/unicorn.rb"
|
|
|
|
|
2014-07-04 03:45:20 -04:00
|
|
|
get_unicorn_pid()
|
2013-10-09 10:45:32 -04:00
|
|
|
{
|
|
|
|
local pid=$(cat $unicorn_pidfile)
|
2014-09-08 08:25:20 -04:00
|
|
|
if [ -z "$pid" ] ; then
|
2013-10-09 10:45:32 -04:00
|
|
|
echo "Could not find a PID in $unicorn_pidfile"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
unicorn_pid=$pid
|
|
|
|
}
|
|
|
|
|
2014-07-04 03:45:20 -04:00
|
|
|
start()
|
2013-10-09 10:45:32 -04:00
|
|
|
{
|
|
|
|
bundle exec unicorn_rails -D -c $unicorn_config -E $RAILS_ENV
|
|
|
|
}
|
|
|
|
|
2014-07-04 03:45:20 -04:00
|
|
|
stop()
|
2013-10-09 10:45:32 -04:00
|
|
|
{
|
|
|
|
get_unicorn_pid
|
|
|
|
kill -QUIT $unicorn_pid
|
|
|
|
}
|
|
|
|
|
2014-07-04 03:45:20 -04:00
|
|
|
reload()
|
2013-10-09 10:45:32 -04:00
|
|
|
{
|
|
|
|
get_unicorn_pid
|
|
|
|
kill -USR2 $unicorn_pid
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
reload
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: RAILS_ENV=your_env $0 {start|stop|reload}"
|
|
|
|
;;
|
|
|
|
esac
|