Class: Waves::Monitor
Instance Method Summary collapse
-
#check ⇒ Object
you need to implement this.
- #fix ⇒ Object
-
#initialize(options) ⇒ Monitor
constructor
A new instance of Monitor.
-
#interval ⇒ Object
defaults to every 60 seconds.
- #start(manager) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options) ⇒ Monitor
Returns a new instance of Monitor.
5 |
# File 'lib/runtime/monitor.rb', line 5 def initialize( ) ; @options = ; end |
Instance Method Details
#check ⇒ Object
you need to implement this
23 |
# File 'lib/runtime/monitor.rb', line 23 def check ; true ; end |
#fix ⇒ Object
18 19 20 |
# File 'lib/runtime/monitor.rb', line 18 def fix @manager.restart end |
#interval ⇒ Object
defaults to every 60 seconds
26 |
# File 'lib/runtime/monitor.rb', line 26 def interval ; @options[ :interval ] ; end |
#start(manager) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/runtime/monitor.rb', line 7 def start( manager ) @manager = manager @pid = fork do safe_trap('INT','TERM') do Waves::Logger.info "Monitor stopped ..." exit end loop { fix unless check ; sleep interval } end end |
#stop ⇒ Object
28 |
# File 'lib/runtime/monitor.rb', line 28 def stop ; Process.kill( 'INT', @pid ) ; end |