blob: 1b918d1fbc4c46619f20f6612c6ddb7d30fa221b (
plain)
1
2
3
4
5
6
7
8
9
10
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
39
40
41
42
43
44
45
46
47
48
|
module Oxidized
require 'oxidized/log'
require 'oxidized/string'
require 'oxidized/config'
require 'oxidized/config/vars'
require 'oxidized/worker'
require 'oxidized/nodes'
require 'oxidized/manager'
require 'oxidized/hook'
class << self
def new *args
Core.new args
end
end
class Core
class NoNodesFound < OxidizedError; end
def initialize args
Config.load
Oxidized.mgr = Manager.new
Oxidized.Hooks = HookManager.from_config(Oxidized.config)
nodes = Nodes.new
raise NoNodesFound, 'source returns no usable nodes' if nodes.size == 0
@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
private
def run
while true
@worker.work
sleep Config::Sleep
end
end
end
end
|