require 'heroku-api' module Delayed module Workless module Scaler class Heroku < Base extend Delayed::Workless::Scaler::HerokuClient def self.up client.put_workers(ENV['APP_NAME'], 1) if workers == 0 end def self.down client.put_workers(ENV['APP_NAME'], 0) unless jobs.count > 0 || workers == 0 end def self.workers client.get_ps(ENV['APP_NAME']).body.count { |p| p['process'] =~ /worker\.\d?/ } end end end end end