Sha256: 3087c15e06e3adddb5b836ec03b59b9b6608ce6a399f91685148e058bd8db165

Contents?: true

Size: 1.91 KB

Versions: 1

Compression:

Stored size: 1.91 KB

Contents

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:		resque
# Required-Start:	$local_fs $remote_fs
# Required-Stop:	$local_fs $remote_fs
# Should-Start:		$local_fs
# Should-Stop:		$local_fs
# Default-Start:	2 3 4 5
# Default-Stop:		0 1 6
# Short-Description:	resque - a Redis-backed Ruby library for creating background jobs
# Description:		resque - a Redis-backed Ruby library for creating background jobs, placing those jobs on multiple queues, and processing them later.
### END INIT INFO

set -e

. /lib/lsb/init-functions

NAME="<%= application %>"
ROOT=<%= current_path %>
USER="<%= resque_user %>"
GROUP="<%= resque_user %>"
ENVIRONMENT="production"
QUEUES="<%= resque_queue %>"
COUNT=<%= resque_workers %>
TASK="<%= resque_task %>"
PIDFILE="$ROOT/tmp/pids/resque_worker.%d.pid"

BUNDLE="<%= resque_bundle %>"

start() {
local program
local options

program=$BUNDLE
options="exec rake $TASK"
options="$options RACK_ENV=$ENVIRONMENT QUEUES=$QUEUES NEWRELIC_DISPATCHER=resque"

for i in $(seq 1 $COUNT); do
pidfile=$(printf "$PIDFILE" $i)

if start-stop-daemon --start --background --quiet --pidfile $pidfile --chdir $ROOT --chuid $USER:$GROUP --exec $program -- $options PIDFILE=$pidfile
then
log_daemon_msg "Starting worker #$i for $NAME ..."
else
log_failure_msg "Failed to start worker #$i for $NAME!"
fi
done
}

stop() {
local pidfile

for i in $(seq 1 $COUNT); do
pidfile=$(printf "$PIDFILE" $i)

if start-stop-daemon --stop --quiet --oknodo --pidfile $pidfile
then
log_daemon_msg "Stopped Resque worker #$i for $NAME"
rm -f $pidfile
else
log_failure_msg "Failed to stop Resque worker #$i for $NAME!" >&2
fi
done
}

status() {
local pidfile

for i in $(seq 1 $COUNT); do
pidfile=$(printf "$PIDFILE" $i)

status_of_proc -p $pidfile "rake $TASK" "$NAME worker #$i"
done
}

case "$1" in
start)	start ;;
stop)	stop ;;
restart|force-reload)
stop
sleep 1
start
;;
status) status ;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kapify-0.0.2 lib/generators/kapify/resque/templates/resque_init.erb