summaryrefslogtreecommitdiff
path: root/lib/oxidized/core.rb
blob: b4f5612a730ab3257c74bb93faf2ed24011b4031 (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
module Oxidized
  require 'oxidized/log'
  require 'oxidized/string'
  require 'oxidized/config'
  require 'oxidized/worker'
  require 'oxidized/nodes'
  require 'oxidized/manager'
  require 'oxidized/api/web'
  class << self
    def new *args
      Core.new args
    end
  end

  class Core
    def initialize args
      Oxidized.mgr = Manager.new
      nodes        = Nodes.new
      @worker      = Worker.new nodes
      if CFG.rest
        @rest        = API::Web.new nodes, CFG.rest
        @rest.run
      end
      run
    end

    private

    def run
      while true
        @worker.work
        sleep Config::Sleep
      end
    end
  end
end