Sha256: 660921c675218c5c1ac0e5db9573c05f8b2e6fd98611cde84de0750722a61b74

Contents?: true

Size: 1017 Bytes

Versions: 2

Compression:

Stored size: 1017 Bytes

Contents

module Oxidized
  class << self
    def new *args
      Core.new args
    end
  end

  class Core
    class NoNodesFound < OxidizedError; end

    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 == 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
      Oxidized.logger.debug "lib/oxidized/core.rb: Starting the worker..."
      while true
        @worker.work
        sleep Config::Sleep
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
oxidized-0.25.1 lib/oxidized/core.rb
oxidized-0.25.0 lib/oxidized/core.rb