Created
March 17, 2011 13:30
-
-
Save tcocca/874303 to your computer and use it in GitHub Desktop.
Monit script for multiple delayed_job workers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
check process sequoia_dj2_delayed_job_0 | |
with pidfile /home/deploy/rails/sequoia/shared/pids/delayed_job.0.pid | |
start program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh start production 0" | |
as uid deploy and gid deploy | |
stop program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh stop production 0" | |
as uid deploy and gid deploy | |
check process sequoia_dj2_delayed_job_1 | |
with pidfile /home/deploy/rails/sequoia/shared/pids/delayed_job.1.pid | |
start program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh start production 1" | |
as uid deploy and gid deploy | |
stop program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh stop production 1" | |
as uid deploy and gid deploy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export PATH="/opt/ruby-enterprise/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH" | |
APP_NAME=sequoia | |
APP_DIR=/home/deploy/rails | |
RAILS_ROOT=$APP_DIR/$APP_NAME/current | |
if [ "$3" ]; then | |
RUNNER="$3" | |
else | |
RUNNER=1 | |
fi | |
ENVIRONMENT=$2 | |
PID_FILE=$RAILS_ROOT/tmp/pids/delayed_job.$RUNNER.pid | |
LOG_FILE=$APP_DIR/$APP_NAME/shared/delayed_job_pid_monit.$RUNNER.log | |
exec 2>&1 | |
exec 1>>$LOG_FILE | |
echo "Runner: $RUNNER" | |
echo "Env: $ENVIRONMENT" | |
echo "Pid: $PID_FILE" | |
cd $RAILS_ROOT | |
echo "Received $1" | |
function stop { | |
RAILS_ENV=$ENVIRONMENT $RAILS_ROOT/script/delayed_job stop -i $RUNNER | |
} | |
function start { | |
if [ -f $PID_FILE ]; then | |
echo "Pid Found. Deleting PID FILE: $PID_FILE" | |
rm -f $PID_FILE | |
fi | |
CMD="/usr/bin/env RAILS_ENV=$ENVIRONMENT $RAILS_ROOT/script/delayed_job start -i $RUNNER" | |
echo $CMD | |
exec $CMD | |
} | |
case $1 in | |
start) | |
stop | |
start | |
;; | |
stop) | |
stop | |
;; | |
*) | |
echo "WTF" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! I used this solution.