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
# 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.size.zero?

  @worker = Worker.new nodes
  trap('HUP') { nodes.load }
  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