Class: Refinery::Monitor

Inherits:
Object
  • Object
show all
Includes:
Configurable, Loggable, Queueable, Utilities
Defined in:
lib/refinery/monitor.rb

Overview

The monitor is responsible for monitoring the health of the various components of refinery.

Instance Method Summary collapse

Methods included from Utilities

#camelize, #decode_message, #encode_message, #host_info

Methods included from Queueable

#queue, #with_queue

Methods included from Configurable

#config, #config=

Methods included from Loggable

#logger

Constructor Details

#initialize(options) ⇒ Monitor

Initialize the monitor.

Options:

  • :verbose: Enable INFO level logging

  • :debug: Enable DEBUG level logging

  • :config: The config file



16
17
18
19
20
21
# File 'lib/refinery/monitor.rb', line 16

def initialize(options)
  logger.level = Logger::INFO if options[:verbose]
  logger.level = Logger::DEBUG if options[:debug]
  config.load_file(options[:config]) if options[:config]
  @queue_prefix = config['prefix'] || ''
end

Instance Method Details

#runObject

Execute the monitor. The monitor will start one heartbeat monitor thread and one thread for each done queue and error queue as specified in the configuration.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/refinery/monitor.rb', line 26

def run
  logger.info "Starting up monitor"
  heartbeat_monitor_thread = run_heartbeat_monitor
  done_monitor_threads = run_done_monitors
  error_monitor_threads = run_error_monitors
  
  logger.info "Monitor running"
  
  Refinery::StatsServer.new.run
  
  begin
    heartbeat_monitor_thread.join
    done_monitor_threads.each { |t| t.join }
    error_monitor_threads.each { |t| t.join }
  rescue Interrupt => e
  end
  
  logger.info "Monitor is exiting"
end