Sha256: 13b4ee86a12f0647232f0c8b3d5880ef8bd932d8ae54ada0f9cd41b2255eada2

Contents?: true

Size: 990 Bytes

Versions: 6

Compression:

Stored size: 990 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.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

    private

    def run
      Oxidized.logger.debug "lib/oxidized/core.rb: Starting the worker..."
      @worker.work while sleep Config::Sleep
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
oxidized-0.28.0 lib/oxidized/core.rb
oxidized-0.27.0 lib/oxidized/core.rb
oxidized-0.26.3 lib/oxidized/core.rb
oxidized-0.26.2 lib/oxidized/core.rb
oxidized-0.26.1 lib/oxidized/core.rb
oxidized-0.26.0 lib/oxidized/core.rb