A custom dispatch servlet for use with WEBrick. It dispatches requests (using the Rails Dispatcher) to the appropriate controller/action. By default, it restricts WEBrick to a managing a single Rails request at a time, but you can change this behavior by setting ActionController::Base.allow_concurrency to true.

Methods
D
Constants
REQUEST_MUTEX = Mutex.new
 
Class Public methods
dispatch(options = {})

Start the WEBrick server with the given options, mounting the DispatchServlet at /.

# File rails/railties/lib/webrick_server.rb, line 50
def self.dispatch(options = {})
  Socket.do_not_reverse_lookup = true # patch for OS X

  params = { :Port        => options[:port].to_i,
             :ServerType  => options[:server_type],
             :BindAddress => options[:ip] }
  params[:MimeTypes] = options[:mime_types] if options[:mime_types]

  server = WEBrick::HTTPServer.new(params)
  server.mount('/', DispatchServlet, options)

  trap("INT") { server.shutdown }
  
  server.start
end