Sha256: c5dff2ce46d806b0f55a9e83198de8a13afc2a85162375704e4114a55c671f60

Contents?: true

Size: 623 Bytes

Versions: 6

Compression:

Stored size: 623 Bytes

Contents

module Waves
  
  class Monitor
    
    def initialize( options ) ; @options = options ; end
    
    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
    
    def fix
      @manager.restart
    end
    
    # you need to implement this
    def check ; true ; end
    
    # defaults to every 60 seconds
    def interval ; @options[ :interval ] ; end
    
    def stop ; Process.kill( 'INT', @pid ) ; end
    
  end
  
end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
dyoder-waves-0.8.0 lib/runtime/monitor.rb
waves-edge-2009.03.10.13.14 lib/runtime/monitor.rb
waves-stable-2009.3.10 lib/runtime/monitor.rb
waves-0.8.1 lib/runtime/monitor.rb
waves-0.8.0 lib/runtime/monitor.rb
waves-0.8.2 lib/runtime/monitor.rb