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

#configuration, #dispatcher

Instance Method Summary collapse

Methods inherited from Webmachine::Adapter

#initialize, run

Constructor Details

This class inherits a constructor from Webmachine::Adapter

Instance Method Details

#runObject

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 => configuration.port,
    :host => configuration.ip,
    :dispatcher => dispatcher
  }.merge(configuration.adapter_options)
  @config = ::Mongrel::Configurator.new(defaults) do
    listener do
      uri '/', :handler => Webmachine::Adapters::Mongrel::Handler.new(defaults[:dispatcher])
    end
    trap("INT") { stop }
    run
  end
  @config.join
end

#shutdownObject



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