読者です 読者をやめる 読者になる 読者になる

[Rails]mongrel 起動スクリプト

参考URL
http://d.hatena.ne.jp/xibbar/20070809#1186643541

#!/bin/bash
#
# chkconfig: 2345 20 80
# description: monrel cluster web server
# processname: mongrel


USER=enquete
RAILS_DIR=/home/enquete/koho_questionnaire
COMMAND=/var/lib/gems/1.8/bin/mongrel_rails

export RAILS_ENV=production

RETVAL=0

# Gracefully exit if the sudo is missing.
which sudo >/dev/null || exit 0

# Gracefully exit if the controller is missing.
which mongrel_rails >/dev/null || exit 0

# Go no further if config directory is missing.
[ -d "$RAILS_DIR" ] || exit 0

case "$1" in
    start)
      # Create pid directory
      echo "Starting... mongrel simple process"
      cd $RAILS_DIR
      sudo -u $USER $COMMAND start -d
      RETVAL=$?
  ;;
    stop)
      cd $RAILS_DIR
      sudo -u $USER $COMMAND stop
      RETVAL=$?
  ;;
    restart)
      cd $RAILS_DIR
      sudo -u $USER $COMMAND restart
      RETVAL=$?
  ;;
    *)
      echo "Usage: mongrel {start|stop|restart}"
      exit 1
  ;;
esac      

exit $RETVAL