Module: Innate::Adapter

### Home Classes Methods

### In Files

- lib/innate/adapter.rb

### Methods

- ::start
- ::start_ebb
- ::start_thin
- ::start_unicorn
- ::start_webrick

### Included Modules

- Innate::Optioned

### Class/Module Index

Quicksearch

- Innate
- Innate::Action
- Innate::Adapter
- Innate::Cache
- Innate::Cache::API
- Innate::Cache::DRb
- Innate::Cache::FileBased
- Innate::Cache::Marshal
- Innate::Cache::Memory
- Innate::Cache::YAML
- Innate::Current
- Innate::Etanni
- Innate::Helper
- Innate::Helper::Aspect
- Innate::Helper::Aspect::SingletonMethods
- Innate::Helper::CGI
- Innate::Helper::Flash
- Innate::Helper::Link
- Innate::Helper::Redirect
- Innate::Helper::Render
- Innate::HelperAccess
- Innate::HelpersHelper
- Innate::LRUHash
- Innate::LogHub
- Innate::Mock
- Innate::Mock::Session
- Innate::Node
- Innate::Optioned
- Innate::Optioned::SingletonMethods
- Innate::Options
- Innate::Request
- Innate::Response
- Innate::Rewrite
- Innate::Route
- Innate::Session
- Innate::Session::Flash
- Innate::SingletonMethods
- Innate::StateAccessor
- Innate::Traited
- Innate::Trinity
- Innate::URLMap
- Innate::View
- Innate::View::ERB
- Innate::View::Etanni
- Innate::View::None
- Logger
- Logger::ColorFormatter
- Object

No matching classes.

# 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
    def self.start(app, given_options = nil)
      options.merge!(given_options) if given_options

      handler = options[:handler].to_s.downcase
      config = { :Host => options[:host], :Port => options[:port] }

      Log.debug "Using #{handler}"

      if respond_to?(method = "start_#{handler}")
        send(method, app, config)
      else
        Rack::Handler.get(handler).run(app, config)
      end
    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
    def self.start_ebb(app, config)
      require 'ebb'
      Rack::Handler.get('ebb').run(app, config)
    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
    def self.start_thin(app, config)
      handler = Rack::Handler.get('thin')
      ::Thin::Logging.silent = true
      handler.run(app, config)
    end

start_unicorn(app, config) click to toggle source

A simple Unicorn wrapper.

    # File lib/innate/adapter.rb, line 79
    def self.start_unicorn(app, config)
      require 'unicorn'
      config = {
        :listeners => ["#{config[:Host]}:#{config[:Port]}"]
      }
      ::Unicorn.run(app, config)
    end

start_webrick(app, config) click to toggle source

We want webrick to use our logger.

    # File lib/innate/adapter.rb, line 60
    def self.start_webrick(app, config)
      handler = Rack::Handler.get('webrick')
      config = {
        :BindAddress => config[:Host],
        :Port => config[:Port],
        :Logger => Log,
      }

      handler.run(app, config)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.