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:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/oxidized/core.rb', line 19

def initialize args
  Oxidized.mgr = Manager.new
  Oxidized.Hooks = HookManager.from_config CFG
  nodes        = Nodes.new
  raise NoNodesFound, 'source returns no usable nodes' if nodes.size == 0
  @worker      = Worker.new nodes
  trap('HUP') { nodes.load }
  if CFG.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, CFG.rest
    @rest.run
  end
  run
end