Sha256: 7afac21b29ef6bc06b9ec74b4e290ce5453bccac2bfae32160c5324afa9a3d5c

Contents?: true

Size: 589 Bytes

Versions: 2

Compression:

Stored size: 589 Bytes

Contents

require 'heroku'

module Delayed
  module Workless
    module Scaler

      class Heroku < Base

        require "heroku"

        def up
          client.set_workers(ENV['APP_NAME'], 1) if workers == 0       
        end

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

        def workers
          client.info(ENV['APP_NAME'])[:workers].to_i
        end

        private

        def client
          @client ||= Heroku::Client.new(ENV['HEROKU_USER'], ENV['HEROKU_PASSWORD'])
        end

      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workless-0.0.2 lib/workless/scalers/heroku.rb
workless-0.0.1 lib/workless/scalers/heroku.rb