Included Modules

Innate::Adapter

Lightweight wrapper around Rack::Handler, will apply our options in a unified manner and deal with adapters that don’t like to do what we want or where Rack doesn’t want to take a stand.

Rack handlers as of 2009.03.25: cgi, fastcgi, mongrel, emongrel, smongrel, webrick, lsws, scgi, thin

Public Class Methods

start(app, given_options = nil) click to toggle source

Pass given app to the Handler, handler is chosen based on config.adapter option. If there is a method named start_name_of_adapter it will be run instead of the default run method of the handler, this makes it easy to define custom startup of handlers for your server of choice.

    # File lib/innate/adapter.rb, line 36
36:     def self.start(app, given_options = nil)
37:       options.merge!(given_options) if given_options
38: 
39:       handler = options[:handler].to_s.downcase
40:       config = { :Host => options[:host], :Port => options[:port] }
41: 
42:       Log.debug "Using #{handler}"
43: 
44:       if respond_to?(method = "start_#{handler}")
45:         send(method, app, config)
46:       else
47:         Rack::Handler.get(handler).run(app, config)
48:       end
49:     end
start_ebb(app, config) click to toggle source

Due to buggy autoload on Ruby 1.8 we have to require ‘ebb’ manually. This most likely happens because autoload doesn’t respect the require of rubygems and uses the C require directly.

    # File lib/innate/adapter.rb, line 54
54:     def self.start_ebb(app, config)
55:       require 'ebb'
56:       Rack::Handler.get('ebb').run(app, config)
57:     end
start_thin(app, config) click to toggle source

Thin shouldn’t give excessive output, especially not to $stdout

    # File lib/innate/adapter.rb, line 72
72:     def self.start_thin(app, config)
73:       handler = Rack::Handler.get('thin')
74:       ::Thin::Logging.silent = true
75:       handler.run(app, config)
76:     end
start_unicorn(app, config) click to toggle source

A simple Unicorn wrapper.

    # File lib/innate/adapter.rb, line 79
79:     def self.start_unicorn(app, config)
80:       require 'unicorn'
81:       config = {
82:         :listeners => ["#{config[:Host]}:#{config[:Port]}"]
83:       }
84:       ::Unicorn.run(app, config)
85:     end
start_webrick(app, config) click to toggle source

We want webrick to use our logger.

    # File lib/innate/adapter.rb, line 60
60:     def self.start_webrick(app, config)
61:       handler = Rack::Handler.get('webrick')
62:       config = {
63:         :BindAddress => config[:Host],
64:         :Port => config[:Port],
65:         :Logger => Log,
66:       }
67: 
68:       handler.run(app, config)
69:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.