Sha256: 52f09e1eb38070b3b05ad146550addaf28eef6b83de9dbcaa2e7676bba056ce9

Contents?: true

Size: 707 Bytes

Versions: 2

Compression:

Stored size: 707 Bytes

Contents

require 'unicorn'
require 'rack/handler'

class Rack::Handler::Unicorn
  def self.server_class
    ::Unicorn::HttpServer
  end

  def self.run app, opts
    server_name = name[/::(\w+)$/, 1].downcase
    config_path = "#{File.dirname(opts[:config])}/config/#{server_name}.rb"
    config_file = config_path if File.exist?(config_path)

    server = initialize_server(app, opts, config_file)

    yield(server) if block_given?

    server.start.join
  end

  def self.initialize_server app, opts, config_file
    server_class.new(app, :listeners   => "#{opts[:Host]}:#{opts[:Port]}",
                          :config_file => config_file)
  end
end

Rack::Handler.register('unicorn', Rack::Handler::Unicorn)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-handlers-0.7.2 lib/rack/handler/unicorn.rb
rack-handlers-0.7.1 lib/rack/handler/unicorn.rb