Skip to content
代码片段 群组 项目
mail_room 788 字节
更新 更旧
Douwe Maan's avatar
Douwe Maan 已提交
#!/bin/sh

Douwe Maan's avatar
Douwe Maan 已提交
app_root=$(pwd)

mail_room_pidfile="$app_root/tmp/pids/mail_room.pid"
Douwe Maan's avatar
Douwe Maan 已提交
mail_room_logfile="$app_root/log/mail_room.log"
Douwe Maan's avatar
Douwe Maan 已提交
mail_room_config="$app_root/config/mail_room.yml"

get_mail_room_pid()
{
  local pid
  pid=$(cat $mail_room_pidfile)
Douwe Maan's avatar
Douwe Maan 已提交
  if [ -z "$pid" ] ; then
    echo "Could not find a PID in $mail_room_pidfile"
    exit 1
  fi
  mail_room_pid=$pid
}

start()
{
  bin/daemon_with_pidfile $mail_room_pidfile bundle exec mail_room --log-exit-as json -q -c $mail_room_config >> $mail_room_logfile 2>&1
Douwe Maan's avatar
Douwe Maan 已提交
}

stop()
{
  get_mail_room_pid
Douwe Maan's avatar
Douwe Maan 已提交
restart()
Douwe Maan's avatar
Douwe Maan 已提交
{
Douwe Maan's avatar
Douwe Maan 已提交
  stop
  start
Douwe Maan's avatar
Douwe Maan 已提交
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
Douwe Maan's avatar
Douwe Maan 已提交
  restart)
    restart
Douwe Maan's avatar
Douwe Maan 已提交
    ;;
  *)
Douwe Maan's avatar
Douwe Maan 已提交
    echo "Usage: $0 {start|stop|restart}"
Douwe Maan's avatar
Douwe Maan 已提交
    ;;
esac