Skip to content

Commit

Permalink
Set all resque processes in a single monit group
Browse files Browse the repository at this point in the history
  • Loading branch information
daronco committed Apr 20, 2015
1 parent a10ef9b commit a75a17e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions config/monit/resque_workers.monitrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ check process resque_worker_1
stop program = "/bin/bash -c '/var/www/mconf-web/current/script/start_resque_workers.sh stop all'"
as uid mconf and gid mconf
if totalmem is greater than 300 MB for 10 cycles then restart # eating up memory?
group resque_workers
group resque

check process resque_worker_2
with pidfile /var/www/mconf-web/current/tmp/pids/resque_worker_2.pid
Expand All @@ -17,7 +17,7 @@ check process resque_worker_2
stop program = "/bin/bash -c '/var/www/mconf-web/current/script/start_resque_workers.sh stop all 2'"
as uid mconf and gid mconf
if totalmem is greater than 300 MB for 10 cycles then restart # eating up memory?
group resque_workers
group resque

check process resque_worker_3
with pidfile /var/www/mconf-web/current/tmp/pids/resque_worker_3.pid
Expand All @@ -26,7 +26,7 @@ check process resque_worker_3
stop program = "/bin/bash -c '/var/www/mconf-web/current/script/start_resque_workers.sh stop all 3'"
as uid mconf and gid mconf
if totalmem is greater than 300 MB for 10 cycles then restart # eating up memory?
group resque_workers
group resque

check process resque_scheduler
with pidfile /var/www/mconf-web/current/tmp/pids/resque_scheduler.pid
Expand All @@ -35,9 +35,10 @@ check process resque_scheduler
stop program = "/bin/bash -c '/var/www/mconf-web/current/script/start_resque_scheduler.sh stop'"
as uid mconf and gid mconf
if totalmem is greater than 300 MB for 10 cycles then restart # eating up memory?
group resque_scheduler
group resque

# to restart the service when we're restarting the application via capistrano
check file resque_restart with path /var/www/mconf-web/current/tmp/restart.txt
if changed timestamp then
exec "/bin/bash -c '/usr/bin/monit -g resque_workers restart; /usr/bin/monit -g resque_scheduler restart;'"
exec "/bin/bash -c '/usr/bin/monit -g resque restart;'"
group resque
4 changes: 2 additions & 2 deletions script/start_resque_workers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ USER="$(id -u -n)"
APP_PATH="$(dirname $0)/.."
PATH=/home/$USER/.rbenv/bin:/home/$USER/.rbenv/shims:$PATH
RAILS_ENV=production
NUM_WORKERS=3
if [ -z "$3" ]; then WORKERNUM=1; else WORKERNUM=$3; fi

if [ "$2" == "all" ]; then
Expand All @@ -35,9 +34,10 @@ cd $APP_PATH

if [ "$1" != "stop" ]; then
if [ "$2" == "all" ]; then
# for all queues
/usr/bin/env bundle exec rake environment resque:work RAILS_ENV=$RAILS_ENV PIDFILE=$PIDFILE QUEUE="*" TERM_CHILD=1 >> $LOGFILE 2>&1 &
else
# for specific queues we run a single worker
# for specific queues
/usr/bin/env bundle exec rake environment resque:work RAILS_ENV=$RAILS_ENV PIDFILE=$PIDFILE QUEUE=$2 TERM_CHILD=1 >> $LOGFILE 2>&1 &
fi
else
Expand Down

0 comments on commit a75a17e

Please sign in to comment.