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"
|
2016-01-14 09:08:15 -05:00
|
|
|
unicorn_cmd="bundle exec unicorn_rails -c $unicorn_config -E $RAILS_ENV"
|
2013-10-09 10:45:32 -04:00
|
|
|
|
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
|
|
|
{
|
2016-04-28 06:11:08 -04:00
|
|
|
exec $unicorn_cmd -D
|
2016-01-14 09:08:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
start_foreground()
|
|
|
|
{
|
2016-04-28 06:11:08 -04:00
|
|
|
exec $unicorn_cmd
|
2013-10-09 10:45:32 -04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
;;
|
2016-01-14 09:08:15 -05:00
|
|
|
start_foreground)
|
|
|
|
start_foreground
|
|
|
|
;;
|
2013-10-09 10:45:32 -04:00
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
reload
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: RAILS_ENV=your_env $0 {start|stop|reload}"
|
|
|
|
;;
|
|
|
|
esac
|