Hello everyone,
Mongrel now has plugins that are based entirely on RubyGems. This feature
was so slick that I decided to bust it out into a separate project called
GemPlugin (more on that later). What the new plugin system does is makes it
so that people can distribute Mongrel plugins as just plain gems, and
mongrel will load them on the fly if people install them. There's no
configuration necessary to get this working, and you can already write your
own mongrel_rails commands.
== What's Mongrel
Mongrel is a fast HTTP library and server for Ruby that is intended for
hosting Ruby web applications of any kind using plain HTTP rather than
FastCGI or SCGI. It is framework agnostic and already supports Ruby On
Rails, Og+Nitro, and Camping frameworks.
== Win32 Warning
I'm holding back win32 people for a day while I test this stuff out more
completely. It has some slightly specific things that I still need to tweak
on win32 to get everything working quite right. Super cool people with
build tools can give this a shot and let me know how it goes. Everyone else
needs to wait, sorry.
== Plugins In Action
The plugin system is actually pretty easy for people to use. Let's say you
do your update:
$ gem update
Which should update mongrel to 0.3.9 and also install a gem_plugin 0.1.
People who haven't used Mongrel before should do this:
$ gem install mongrel
Which will again install gem_plugin as a dependency.
To see how the demo works, just run mongrel_rails and see what commands are
available.
Now for the cool part. Find a Rails application and run it in daemon mode:
$ cd myapp
$ mongrel_rails start -d
Ok, now lets install the new mongrel_status plugin and use it to get the
PID:
$ sudo gem install mongrel_status
$ mongrel_rails status
If everything worked it should spit out the PID of whatever is running. If
you now do mongrel_rails you'll see that there's this new "status" command.
Feel free to do this too:
$ mongrel_rails status -h
Big deal right? Ok, remove it and watch the status command go away:
$ sudo gem uninstall mongrel_status
$ mongrel_rails
See, no more status command.
== How It Works
I'm still wrestling with the explanation of how GemPlugin works, but go
ahead and read:
http://mongrel.rubyforge.org/gem_plugin_rdoc/
To get an idea. It's weird but works fantastic.
== Next Steps
In the push to 0.4 I'll be implementing handlers and filters as plugins and
setting up the "grand config system" so that you can attach them to URIs.
This should be point at which people can literally write their own plugins
and extensions to Mongrel without much extra effort.
Enjoy! And please post the bugs.
Zed A. Shaw
http://www.zedshaw.com/