Class: Oxidized::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/oxidized/core.rb

Defined Under Namespace

Classes: NoNodesFound

Instance Method Summary collapse

Constructor Details

#initialize(_args) ⇒ Core

Returns a new instance of Core.

Raises:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/oxidized/core.rb', line 11

def initialize(_args)
  Oxidized.mgr = Manager.new
  Oxidized.hooks = HookManager.from_config(Oxidized.config)
  nodes = Nodes.new
  raise NoNodesFound, 'source returns no usable nodes' if nodes.empty?

  @worker = Worker.new nodes
  @need_reload = false

  # If we receive a SIGHUP, queue a reload of the state
  reload_proc = proc do
    @need_reload = true
  end
  Signals.register_signal('HUP', reload_proc)

  # Initialize REST API and webUI if requested
  if Oxidized.config.rest?
    begin
      require 'oxidized/web'
    rescue LoadError
      raise OxidizedError, 'oxidized-web not found: sudo gem install oxidized-web - \
      or disable web support by setting "rest: false" in your configuration'
    end
    @rest = API::Web.new nodes, Oxidized.config.rest
    @rest.run
  end
  run
end