BigW Consortium Gitlab

mail_room 753 Bytes
Newer Older
Douwe Maan committed
1 2 3 4 5 6
#!/bin/sh

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

mail_room_pidfile="$app_root/tmp/pids/mail_room.pid"
Douwe Maan committed
7
mail_room_logfile="$app_root/log/mail_room.log"
Douwe Maan committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21
mail_room_config="$app_root/config/mail_room.yml"

get_mail_room_pid()
{
  local pid=$(cat $mail_room_pidfile)
  if [ -z "$pid" ] ; then
    echo "Could not find a PID in $mail_room_pidfile"
    exit 1
  fi
  mail_room_pid=$pid
}

start()
{
22
  bin/daemon_with_pidfile $mail_room_pidfile bundle exec mail_room -q -c $mail_room_config >> $mail_room_logfile 2>&1
Douwe Maan committed
23 24 25 26 27
}

stop()
{
  get_mail_room_pid
Douwe Maan committed
28
  kill -TERM $mail_room_pid
Douwe Maan committed
29 30
}

Douwe Maan committed
31
restart()
Douwe Maan committed
32
{
Douwe Maan committed
33 34
  stop
  start
Douwe Maan committed
35 36 37 38 39 40 41 42 43
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
Douwe Maan committed
44 45
  restart)
    restart
Douwe Maan committed
46 47
    ;;
  *)
Douwe Maan committed
48
    echo "Usage: $0 {start|stop|restart}"
Douwe Maan committed
49 50
    ;;
esac