Sha256: b1719a554d12ee4ab86378327ad6780248380919b616c1822d7a5bcf967f094c

Contents?: true

Size: 549 Bytes

Versions: 7

Compression:

Stored size: 549 Bytes

Contents

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 self.workers == 0
        end

        def self.down
          client.put_workers(ENV['APP_NAME'], 0) unless self.jobs.count > 0 or self.workers == 0
        end

        def self.workers
          client.get_ps(ENV['APP_NAME']).body.count { |p| p["process"] =~ /worker\.\d?/ }
        end

      end

    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
workless_revived-1.2.4.2 lib/workless/scalers/heroku.rb
workless_revived-1.2.4 lib/workless/scalers/heroku.rb
workless-1.2.3 lib/workless/scalers/heroku.rb
workless-1.2.2 lib/workless/scalers/heroku.rb
workless-1.2.1 lib/workless/scalers/heroku.rb
workless-1.2.0 lib/workless/scalers/heroku.rb
workless-1.1.3 lib/workless/scalers/heroku.rb