Class: Waves::Monitor

Inherits:
Object show all
Defined in:
lib/runtime/monitor.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Monitor

Returns a new instance of Monitor.



5
# File 'lib/runtime/monitor.rb', line 5

def initialize( options ) ; @options = options ; end

Instance Method Details

#checkObject

you need to implement this



23
# File 'lib/runtime/monitor.rb', line 23

def check ; true ; end

#fixObject



18
19
20
# File 'lib/runtime/monitor.rb', line 18

def fix
  @manager.restart
end

#intervalObject

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

#stopObject



28
# File 'lib/runtime/monitor.rb', line 28

def stop ; Process.kill( 'INT', @pid ) ; end