Skip to content

Instantly share code, notes, and snippets.

@evopix
Created October 20, 2012 01:38
Show Gist options
  • Save evopix/3921634 to your computer and use it in GitHub Desktop.
Save evopix/3921634 to your computer and use it in GitHub Desktop.
Kohana Resque Init Script
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: php-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 PHP library for creating background jobs
# Description: resque - a Redis-backed PHP library for creating background jobs, placing those jobs on multiple queues, and processing them later.
### END INIT INFO
set -e
ENV="development"
ROOT="/vagrant"
QUEUES="*"
COUNT=2
VERBOSE=1
MINION="$ROOT/minion"
TASK="resque"
start() {
local program
local options
program="$MINION"
options="$TASK"
options="$options --resque=$QUEUES --count=$COUNT --verbose=$VERBOSE --env=$ENV"
cd $ROOT
echo "Starting $NAME workers ..."
$program $options >> /dev/null
}
stop() {
local program
local options
program="$MINION"
options="$TASK"
options="$options --shutdown --env=$ENV"
cd $ROOT
echo "Stopping $NAME workers ..."
$program $options
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment