MicroRails

Posted by stoyan

minimal = KISS = i like it :)

  • Camping is a web framework which consistently stays at less than 4kb of code.
  • Mosquito is a simple test framework for why the lucky stiff’s Camping web library. It provides simple hooks and a few assertions for doing unit and functional tests on your Camping models and controllers.
  • MicroTest . see also Archive for the ’Ruby’ Category
  • ComatoseComatose is a micro CMS, implemented as a Rails plugin, that is designed to be easy to embed and extend.

Webserver with Mongrel

Posted by stoyan

After seen a small webservers in Perl and Ruby 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 ;)