[Mongrel] 0.3.12 Pre-Release Gems Available

Zed Shaw zedshaw at zedshaw.com
Wed Mar 22 02:14:45 EST 2006

Hi Folks,

I'd love for everyone to grab the 0.3.12 pre-release gems from
http://mongrel.rubyforge.org/releases/ and tell me if their stuff breaks.
You can get it with a simple:

gem install mongrel --source=http://mongrel.rubyforge.org/releases/

This release features the following goodies:

* The -n and -t options to mongrel_rails start have changed in meaning to be
the maximum number of concurrent processors and a throttle timeout between
requests.  This fits with the new thread model mongrel is sporting that is
faster and a bit easier to manage.  It will quite possibly produce too many
DB connections from AR though.
* You can now make handlers that are gem plugins.
* You can now use the Mongrel::Configurator to wire up a mongrel server
really quickly (example below).
* You can now add as many handlers as you want to any URI and they will be
processed in order until one of them finalizes the response object. This
means that you can do chained request processing, request filters, response
filters, and lots of other goodies.
* You can use the DSL (Domain Specific Language) to create any number of
port listeners with any number of URIs that have chained handlers on them.

Here's an example DSL loading script:

require 'mongrel'

class TestPlugin < GemPlugin::Plugin "/handlers"
  include Mongrel::HttpHandlerPlugin

  def process(request, response)
    STDERR.puts "My options are: #{options.inspect}"
    STDERR.puts "Request Was:"
    STDERR.puts request.params.to_yaml

config = Mongrel::Configurator.new :host => "" do
  load_plugins :includes => ["mongrel"], :excludes => ["rails"]
  daemonize :cwd => Dir.pwd, :log_file => "mongrel.log", :pid_file =>
  listener :port => 3000 do
    uri "/app", :handler => plugin("/handlers/testplugin", :test => "that")
    uri "/app", :handler => Mongrel::DirHandler.new(".")
    load_plugins :includes => ["mongrel", "rails"]

  trap("INT") { stop }


This is doing a lot but it's very cool stuff.  First creates a handler that
will act as a filter and is also a gem plugin.  Then it makes a mongrel
configuration using the Configurator.  Then it loads plugins (but not
rails), daemonizes, sets up a listener on port 3000, and attaches the
/handlers/testplugin (remember TestPlugin?) and finally DirHandler to the
/app URI.  Last thing is it tells it to run and then goes.

Please try out the gems with your existing stuff and report breakage.


More information about the Mongrel-users mailing list