Sha256: 7c50043c1cae96041f38f287d5f3b2891ca5d97bc9ac1edc61606fbcca50c3bc

Contents?: true

Size: 589 Bytes

Versions: 3

Compression:

Stored size: 589 Bytes

Contents

require 'heroku'

module Delayed
  module Workless
    module Scaler

      class HerokuCedar < Base

        extend Delayed::Workless::Scaler::HerokuClient

        def self.up
          client.ps_scale(ENV['APP_NAME'], :type => 'worker', :qty => 1) if self.workers == 0
        end

        def self.down
          client.ps_scale(ENV['APP_NAME'], :type => 'worker', :qty => 0) unless self.workers == 0 or self.jobs.count > 0
        end

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

      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workless-1.0.2 lib/workless/scalers/heroku_cedar.rb
workless-1.0.1 lib/workless/scalers/heroku_cedar.rb
workless-1.0.0 lib/workless/scalers/heroku_cedar.rb