Class: Moro::Daemon

Inherits:
Object
  • Object
show all
Defined in:
lib/moro/daemon.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Daemon

Returns a new instance of Daemon.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/moro/daemon.rb', line 8

def initialize(config)
  @monitor=Monitor.new(config)
  build_handlers(config)
  puts config

  if config["interval"]!=nil
    @interval=config["interval"]
  else
    @interval=30
  end
end

Instance Method Details

#startObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/moro/daemon.rb', line 20

def start()
  start_message="start moro daemon"
  stop_message="stop moro daemon"
  puts start_message
  Moro.logger.info start_message

  at_exit do
    puts stop_message
    Moro.logger.info stop_message
  end

  while true
    process_usages=@monitor.monit

    @handlers.each do |handler|
      handler.send(process_usages)
    end

    Moro.logger.info "stats memory"
    sleep(@interval)
  end
end