Module: HerokuResqueAutoScale::Scaler

Defined in:
lib/heroku_resque_auto_scale.rb

Constant Summary collapse

@@heroku =
Heroku::API.new(api_key: ENV['HEROKU_API_KEY'])

Class Method Summary collapse

Class Method Details

.job_countObject



17
18
19
# File 'lib/heroku_resque_auto_scale.rb', line 17

def job_count
  Resque.info[:pending].to_i
end

.workersObject



9
10
11
# File 'lib/heroku_resque_auto_scale.rb', line 9

def workers
  @@heroku.get_ps(ENV['HEROKU_APP']).body.count { |a| a["process"] =~ /worker/ }
end

.workers=(qty) ⇒ Object



13
14
15
# File 'lib/heroku_resque_auto_scale.rb', line 13

def workers=(qty)
  @@heroku.post_ps_scale(ENV['HEROKU_APP'], 'worker', qty)
end