Module: Scalehero::Scaler
- Defined in:
- lib/scalehero.rb
Constant Summary collapse
- @@heroku =
Heroku::API.new(:api_key => ENV['HEROKU_API_KEY'])
Class Method Summary collapse
- .has_one_working_job? ⇒ Boolean
- .pending_jobs_count ⇒ Object
- .workers ⇒ Object
- .workers=(q) ⇒ Object
- .working_jobs_count ⇒ Object
Class Method Details
.has_one_working_job? ⇒ Boolean
26 27 28 |
# File 'lib/scalehero.rb', line 26 def has_one_working_job? Resque.info[:working] == 1 end |
.pending_jobs_count ⇒ Object
18 19 20 |
# File 'lib/scalehero.rb', line 18 def pending_jobs_count Resque.info[:pending] end |
.workers ⇒ Object
9 10 11 12 |
# File 'lib/scalehero.rb', line 9 def workers ps = @@heroku.get_ps(ENV['HEROKU_APP']) ps.body.collect{|p| p["process"] if p["process"] =~ /worker\.\d?/}.compact end |
.workers=(q) ⇒ Object
14 15 16 |
# File 'lib/scalehero.rb', line 14 def workers=(q) @@heroku.post_ps_scale(ENV['HEROKU_APP'], 'worker', q) end |
.working_jobs_count ⇒ Object
22 23 24 |
# File 'lib/scalehero.rb', line 22 def working_jobs_count Resque.info[:working] end |