Sha256: d21747cf7d617d97ab44b6d2310412174450ed1bd6693d37e5a43ec03101271e

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

module Ocp::Registry
  class Runner
    include YamlHelper

    def initialize(config_file)
      Ocp::Registry.configure(load_yaml_file(config_file))

      @logger = Ocp::Registry.logger
      @http_port = Ocp::Registry.http_port
      @http_user = Ocp::Registry.http_user
      @http_password = Ocp::Registry.http_password
    end

    def run
      @logger.info("OCP Registry starting...")
      start_http_server
    end

    def stop
      @logger.info("OCP Registry shutting down...")
      @http_server.stop! if @http_server
    end

    def start_http_server
      @logger.info "HTTP server is starting on port #{@http_port}..."
      @http_server = Thin::Server.new("0.0.0.0", @http_port, :signals => false) do
        Thin::Logging.silent = true
        map "/" do
          run Ocp::Registry::ApiController.new
        end
      end
      @http_server.start!
    end

    private

    def handle_em_error(e, level = :fatal)
      @logger.send(level, e.to_s)
      if e.respond_to?(:backtrace) && e.backtrace.respond_to?(:join)
        @logger.send(level, e.backtrace.join("\n"))
      end
      stop
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ocp_registry-0.0.5.pre lib/ocp_registry/runner.rb
ocp_registry-0.0.1.alpha lib/ocp_registry/runner.rb