Return to Snippet

Revision: 712
at August 1, 2006 23:20 by ishikawa


Initial Code
#!/usr/bin/ruby

require 'webrick'
include WEBrick

def start_webrick(config = {})
  config.update(:Port => 5001)
  server = HTTPServer.new(config)

  yield server if block_given?
  ['INT', 'TERM'].each do |signal|
    trap(signal) { server.shutdown }
  end
  
  server.start
end

start_webrick(:DocumentRoot => 'path-to-document-root',
              :ServerType => Daemon)

Initial URL


Initial Description
Simple HTTP server daemon (webrick).

Initial Title
Simple webrick server

Initial Tags
server, ruby

Initial Language
Ruby