Class: MonitorManager
- Inherits:
-
Object
- Object
- MonitorManager
- Defined in:
- lib/monitor_manager.rb
Overview
Monitor Manager
Instance Method Summary collapse
- #add(monitor) ⇒ Object
-
#initialize ⇒ MonitorManager
constructor
A new instance of MonitorManager.
-
#run ⇒ Object
The main run loop.
Constructor Details
#initialize ⇒ MonitorManager
Returns a new instance of MonitorManager.
3 4 5 |
# File 'lib/monitor_manager.rb', line 3 def initialize @list = [] end |
Instance Method Details
#add(monitor) ⇒ Object
7 8 9 |
# File 'lib/monitor_manager.rb', line 7 def add(monitor) @list.push monitor end |
#run ⇒ Object
The main run loop
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/monitor_manager.rb', line 12 def run Kernel.loop do @list.each do |m| begin m.run rescue MonitorTypeExceptionHandled => e m.alert(e.) end end sleep 0.2 exit unless ENV['RUN_ONCE'].nil? end rescue Interrupt string = "Exiting on request ...\n" puts string rescue StandardError => e puts '*** This is really unexpected.' puts e.class.name puts "Message: #{e.}" puts e.backtrace end |