Skip to content

Instantly share code, notes, and snippets.

@ishikawa
Created July 26, 2008 03:00
Show Gist options
  • Save ishikawa/2585 to your computer and use it in GitHub Desktop.
Save ishikawa/2585 to your computer and use it in GitHub Desktop.
#!/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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment