Sha256: fed8e1e7f9945d943753003289f7c2dd12120dc5fc42e71168a5acf1f770312d

Contents?: true

Size: 1.44 KB

Versions: 3

Compression:

Stored size: 1.44 KB

Contents

#!/bin/sh
#
# This script starts and stops the Resque Web front end
# This script belongs in /engineyard/bin/resque-web
#
PATH=/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH

usage() {
  echo "Usage: $0 <appname> {start|stop}"
  exit 1
}

if [ $# -lt 2 ]; then usage; fi

if [ "`whoami`" != "root" ]; then
  logger -t `basename $0` -s "Must be run as root"
  exit 1
fi

USER=`stat -c"%U" /data/$1/current`
HOME="/home/$USER" ; export HOME
APP=$1
APP_DIR="/data/${APP}"
APP_ROOT="${APP_DIR}/current"
APP_SHARED="${APP_DIR}/shared"
APP_CONFIG="${APP_SHARED}/config"

GEMFILE="$APP_ROOT/Gemfile"
BUNDLER=""
if [ -f $GEMFILE ];then
  BUNDLER="bundle exec"
fi

COMMAND="$BUNDLER resque-web -p 8282"
PID_FILE="/var/run/engineyard/resque/$1/resque-web.pid"

#mkdir -p /var/run/engineyard/resque/

# handle the second param, don't start if already existing
case "$2" in
  start)
    echo "Starting Resque Web"
    cd /data/$1/current
    if [ -f $PID_FILE ]; then
      PID=`cat $PID_FILE`
      if [ -d /proc/$PID ]; then
        echo "Resque Web is already running."
        exit 1
      fi
      rm -f $PID_FILE
    fi
    echo $$ > $PID_FILE
    logger -t "monit-resque-web[$$]" "Starting with: ${COMMAND}"
    exec su -c"$COMMAND -f" $USER
    ;;
  stop)
    echo "Stopping Resque Web"
    if [ -f $PID_FILE ]; then
      kill -15 `cat $PID_FILE` 2>/dev/null; true
    fi

    [ -e "$PID_FILE" ] && rm -f $PID_FILE
    exit 0
    ;;
  *)
    usage
    ;;
esac

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eycloud-recipe-resque-1.1.1 files/default/resque-web
eycloud-recipe-resque-1.1.0 files/default/resque-web
eycloud-recipe-resque-1.0.3 files/default/resque-web