Permalink
Browse files

Merge pull request #3 from vicentemundim/master

Do not scale down workers if there are more than one working worker
  • Loading branch information...
2 parents 4dc4881 + aeb2c0f commit 7e0660b535b58f3974ab69a394aa3065c58e4b10 @markquezada committed Sep 17, 2012
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/heroku-resque-auto-scale.rb
@@ -10,18 +10,23 @@ def workers
end
def workers=(qty)
- @@heroku.set_workers(ENV['HEROKU_APP'], qty)
+ @@heroku.ps_scale(ENV['HEROKU_APP'], :type => :worker, :qty => qty)
end
def job_count
Resque.info[:pending].to_i
end
+
+ def working_job_count
+ Resque.info[:working].to_i
+ end
end
end
def after_perform_scale_down(*args)
- # Nothing fancy, just shut everything down if we have no jobs
- Scaler.workers = 0 if Scaler.job_count.zero?
+ # Nothing fancy, just shut everything down if we have no pending jobs
+ # and one working job (which is this job)
+ Scaler.workers = 0 if Scaler.job_count.zero? && Scaler.working_job_count == 1
end
def after_enqueue_scale_up(*args)

0 comments on commit 7e0660b

Please sign in to comment.