2019-09-30 21:07:59 +05:30
|
|
|
#!/bin/sh
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
cd $(dirname $0)/.. || exit 1
|
2019-09-30 21:07:59 +05:30
|
|
|
app_root=$(pwd)
|
|
|
|
|
|
|
|
unicorn_pidfile="$app_root/tmp/pids/unicorn.pid"
|
|
|
|
unicorn_config="$app_root/config/unicorn.rb"
|
|
|
|
unicorn_cmd="bundle exec unicorn_rails -c $unicorn_config -E $RAILS_ENV"
|
|
|
|
|
|
|
|
get_unicorn_pid()
|
|
|
|
{
|
2021-01-29 00:20:46 +05:30
|
|
|
local pid
|
|
|
|
pid=$(cat $unicorn_pidfile)
|
2019-09-30 21:07:59 +05:30
|
|
|
if [ -z "$pid" ] ; then
|
|
|
|
echo "Could not find a PID in $unicorn_pidfile"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
unicorn_pid=$pid
|
|
|
|
}
|
|
|
|
|
|
|
|
start()
|
|
|
|
{
|
|
|
|
exec $unicorn_cmd -D
|
|
|
|
}
|
|
|
|
|
|
|
|
start_foreground()
|
|
|
|
{
|
|
|
|
exec $unicorn_cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
stop()
|
|
|
|
{
|
|
|
|
get_unicorn_pid
|
|
|
|
kill -QUIT $unicorn_pid
|
|
|
|
}
|
|
|
|
|
|
|
|
reload()
|
|
|
|
{
|
|
|
|
get_unicorn_pid
|
|
|
|
kill -USR2 $unicorn_pid
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
start_foreground)
|
|
|
|
start_foreground
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
reload
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: RAILS_ENV=your_env $0 {start|stop|reload}"
|
|
|
|
;;
|
|
|
|
esac
|