Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
compare: c87376c8a246c62fbaa11b037c80c1fbd1ce1a6e
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Showing with 21 additions and 1 deletion.
  1. +20 −1 README.md
  2. +1 −0  lib/resque/plugins/resque_heroku_autoscaler.rb
View
21 README.md
@@ -23,6 +23,16 @@ If you prefer you also can configure RHA using a config block. For example you m
c.heroku_app = "my_app_#{Rails.env}"
end
+Or if you are on the Cedar stack
+
+ require 'resque/plugins/resque_heroku_autoscaler'
+
+ Resque::Plugins::HerokuAutoscaler::Cedar.config do |c|
+ c.heroku_user = 'john doe'
+ c.heroku_pass = ENV['HEROKU_PASSWORD']
+ c.heroku_app = "my_app_#{Rails.env}"
+ end
+
To use RHA in one of your jobs, just extend your job class with Resque::Plugins::HerokuAutoscaler.
@@ -31,6 +41,7 @@ For example:
require 'resque/plugins/resque_heroku_autoscaler'
class TestJob
+ # extend Resque::Plugins::HerokuAutoscaler::Cedar
extend Resque::Plugins::HerokuAutoscaler
@queue = :test
@@ -40,6 +51,12 @@ For example:
end
end
+Or on Cedar stack
+
+ class TestJob
+ extend Resque::Plugins::HerokuAutoscaler::Cedar
+ ...
+
When you add the job to your Resque queue, a new worker will be started if there isn't already one. If all jobs in the queue are processed the worker will be stopped again, keeping your costs low.
Per default RHA will only start a single worker, no matter how many jobs are pending. You can change this behavior in the config block as well:
@@ -48,7 +65,7 @@ Per default RHA will only start a single worker, no matter how many jobs are pen
Resque::Plugins::HerokuAutoscaler.config do |c|
c.new_worker_count do |pending|
- (pending/5).ceil.to_i
+ (pending/5.0).ceil.to_i
end
end
@@ -62,7 +79,9 @@ You might want to turn off scaling of your workers in development modus. You can
end
end
+You also need to create a `Procfile` at the root of your project if you don't already have one with the following:
+ worker: QUEUE=* bundle exec rake resque:work
[dh]: http://blog.darkhax.com/2010/07/30/auto-scale-your-resque-workers-on-heroku
[rq]: http://github.com/defunkt/resque
View
1  lib/resque/plugins/resque_heroku_autoscaler.rb
@@ -62,6 +62,7 @@ def scale
new_count = Resque::Plugins::HerokuAutoscaler::Config.new_worker_count(Resque.info[:pending])
set_workers(new_count) if new_count == 0 || new_count > current_workers
Resque.redis.set('last_scaled', Time.now)
+ exit if new_count == 0
end
def wait_for_task_or_scale

No commit comments for this range

Something went wrong with that request. Please try again.