Class: Heroku::Scalr::Runner
- Inherits:
-
Object
- Object
- Heroku::Scalr::Runner
- Defined in:
- lib/heroku/scalr/runner.rb
Constant Summary collapse
- SIGNALS =
%w[HUP INT TERM] & Signal.list.keys
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config_path) ⇒ Runner
constructor
A new instance of Runner.
-
#run! ⇒ Object
Start the runner.
-
#stop! ⇒ Object
Stop execution.
-
#timers ⇒ Timers
Recurring timers.
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/heroku/scalr/runner.rb', line 4 def config @config end |
Instance Method Details
#run! ⇒ Object
Start the runner
22 23 24 25 26 27 28 29 |
# File 'lib/heroku/scalr/runner.rb', line 22 def run! SIGNALS.each do |sig| Signal.trap(sig) { stop! } end Signal.trap("USR1") { Heroku::Scalr.logger.reopen } loop { timers.wait } end |
#stop! ⇒ Object
Stop execution
32 33 34 35 |
# File 'lib/heroku/scalr/runner.rb', line 32 def stop! Heroku::Scalr.logger.info "Exiting ..." exit(0) end |
#timers ⇒ Timers
Returns recurring timers.
12 13 14 15 16 17 18 19 |
# File 'lib/heroku/scalr/runner.rb', line 12 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 |