Sha256: df38b55d4b079cbbb558a92b57cf22faabe9f4ae4939e1038851bddea295b1c6

Contents?: true

Size: 729 Bytes

Versions: 3

Compression:

Stored size: 729 Bytes

Contents

class Heroku::Scalr::Runner
  SIGNALS = %w[HUP INT TERM] & Signal.list.keys

  attr_reader :config

  # @param [String] config_path configuration file location
  def initialize(config_path)
    @config = Heroku::Scalr::Config.new(config_path)
  end

  # @return [Timers] recurring timers
  def timers
    @timers ||= Timers.new.tap do |t|
      config.apps.each do |app|
        app.log :info, "monitoring every #{app.interval}s"
        t.every(app.interval) { app.scale! }
      end
    end
  end

  # Start the runner
  def run!
    SIGNALS.each do |sig|
      Signal.trap(sig) { stop! }
    end

    loop { timers.wait }
  end

  # Stop execution
  def stop!
    Heroku::Scalr.logger.info "Exiting ..."
    exit(0)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
heroku-scalr-0.2.3 lib/heroku/scalr/runner.rb
heroku-scalr-0.2.2 lib/heroku/scalr/runner.rb
heroku-scalr-0.2.1 lib/heroku/scalr/runner.rb