Class: Webmachine::Adapters::Mongrel

Inherits:
Webmachine::Adapter show all
Defined in:
lib/webmachine/adapters/mongrel.rb

Overview

Connects Webmachine to Mongrel.

Defined Under Namespace

Classes: Handler, RequestBody

Instance Attribute Summary

Attributes inherited from Webmachine::Adapter

#application

Instance Method Summary (collapse)

Methods inherited from Webmachine::Adapter

#initialize, run

Constructor Details

This class inherits a constructor from Webmachine::Adapter

Instance Method Details

- (Object) run

Starts the Mongrel adapter



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/webmachine/adapters/mongrel.rb', line 15

def run
  defaults = {
    :port => application.configuration.port,
    :host => application.configuration.ip,
    :application => application
  }.merge(application.configuration.adapter_options)
  @config = ::Mongrel::Configurator.new(defaults) do
    listener do
      uri '/', :handler => Webmachine::Adapters::Mongrel::Handler.new(defaults[:application])
    end
    trap("INT") { stop }
    run
  end
  @config.join
end

- (Object) shutdown



31
32
33
34
35
# File 'lib/webmachine/adapters/mongrel.rb', line 31

def shutdown
  # The second argument tells mongrel to block until all listeners are shut down.
  # This causes the mongrel tests to be very slow, but faster methods cause errors.
  @config.stop(false, true) if @config
end