Class: Resque::Plugins::HerokuScaler::Manager::Heroku

Inherits:
Object
  • Object
show all
Defined in:
lib/resque/plugins/heroku_scaler/manager/heroku.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Heroku

Returns a new instance of Heroku.



9
10
11
# File 'lib/resque/plugins/heroku_scaler/manager/heroku.rb', line 9

def initialize(options={})
  @heroku = ::Heroku::Client.new(ENV['HEROKU_USERNAME'], ENV['HEROKU_PASSWORD'])
end

Instance Method Details

#workersObject



13
14
15
# File 'lib/resque/plugins/heroku_scaler/manager/heroku.rb', line 13

def workers
  @heroku.ps(ENV['HEROKU_APP']).count { |p| p["process"] =~ /worker\.\d?/ }
end

#workers=(qty) ⇒ Object



17
18
19
# File 'lib/resque/plugins/heroku_scaler/manager/heroku.rb', line 17

def workers=(qty)
  @heroku.ps_scale(ENV['HEROKU_APP'], :type => 'worker', :qty => qty)
end