Webserver with Mongrel
After seen a small webservers in Perl and Ruby (webrick) here is my try with using Mongrel:
Start an webserver on all interfaces (0.0.0.0), port 3002, serving static pages from ./html/ directory:
require 'mongrel' config = Mongrel::Configurator.new :host => "0.0.0.0", :port => 3002 do listener { uri "/", :handler => Mongrel::DirHandler.new("html/") } trap("INT") { stop } run end config.join
And with adding some statistics (on http://.../status/ URL):
#!/usr/bin/env ruby require 'rubygems' require 'mongrel' require 'yaml' stats = Mongrel::StatisticsFilter.new(:sample_rate => 1) config = Mongrel::Configurator.new :host => "0.0.0.0", :port => 3002 do listener do uri "/", :handler => Mongrel::DirHandler.new("html/") uri "/", :handler => stats uri "/status", :handler => Mongrel::StatusHandler.new(:stats_filter => stats) end trap("INT") { stop } run end puts "Mongrel running on 0.0.0.0:3002 with docroot ./html/" config.join
I'm using it for serving static pages, generated with Rote - pretty fast ;)