Sha256: bf9baf1e44344725255c89b9881d03b80bb919584d32ec65409a17990630c046

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

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

10 entries across 10 versions & 1 rubygems

Version Path
oxidized-0.21.0 lib/oxidized/core.rb
oxidized-0.20.0 lib/oxidized/core.rb
oxidized-0.19.0 lib/oxidized/core.rb
oxidized-0.18.0 lib/oxidized/core.rb
oxidized-0.17.0 lib/oxidized/core.rb
oxidized-0.16.3 lib/oxidized/core.rb
oxidized-0.16.2 lib/oxidized/core.rb
oxidized-0.16.1 lib/oxidized/core.rb
oxidized-0.16.0 lib/oxidized/core.rb
oxidized-0.15.0 lib/oxidized/core.rb