Class: Sensu::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/sensu/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



21
22
23
# File 'lib/sensu/base.rb', line 21

def initialize(options={})
  @options = DEFAULT_OPTIONS.merge(options)
end

Instance Method Details

#extensionsObject



45
46
47
48
49
50
51
52
# File 'lib/sensu/base.rb', line 45

def extensions
  extensions = Extensions.new
  if @options[:extension_dir]
    extensions.require_directory(@options[:extension_dir])
  end
  extensions.load_all
  extensions
end

#loggerObject



25
26
27
28
29
30
31
32
33
# File 'lib/sensu/base.rb', line 25

def logger
  stream = LogStream.new
  stream.level = @options[:log_level]
  if @options[:log_file]
    stream.reopen(@options[:log_file])
  end
  stream.setup_traps
  stream.logger
end

#settingsObject



35
36
37
38
39
40
41
42
43
# File 'lib/sensu/base.rb', line 35

def settings
  settings = Settings.new
  settings.load_env
  settings.load_file(@options[:config_file])
  settings.load_directory(@options[:config_dir])
  settings.validate
  settings.set_env
  settings
end

#setup_processObject



54
55
56
57
58
59
60
61
62
63
# File 'lib/sensu/base.rb', line 54

def setup_process
  process = Process.new
  if @options[:daemonize]
    process.daemonize
  end
  if @options[:pid_file]
    process.write_pid(@options[:pid_file])
  end
  process.setup_eventmachine
end