web 674 Bytes
Newer Older
Pavel Novitskiy's avatar
Pavel Novitskiy committed
1
#!/bin/sh
2 3 4 5 6 7 8

cd $(dirname $0)/..
app_root=$(pwd)

unicorn_pidfile="$app_root/tmp/pids/unicorn.pid"
unicorn_config="$app_root/config/unicorn.rb"

Pavel Novitskiy's avatar
Pavel Novitskiy committed
9
get_unicorn_pid()
10 11
{
  local pid=$(cat $unicorn_pidfile)
12
  if [ -z "$pid" ] ; then
13 14 15 16 17 18
    echo "Could not find a PID in $unicorn_pidfile"
    exit 1
  fi
  unicorn_pid=$pid
}

Pavel Novitskiy's avatar
Pavel Novitskiy committed
19
start()
20 21 22 23
{
  bundle exec unicorn_rails -D -c $unicorn_config -E $RAILS_ENV
}

Pavel Novitskiy's avatar
Pavel Novitskiy committed
24
stop()
25 26 27 28 29
{
  get_unicorn_pid
  kill -QUIT $unicorn_pid
}

Pavel Novitskiy's avatar
Pavel Novitskiy committed
30
reload()
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
{
  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