Skip to content

Instantly share code, notes, and snippets.

@brettbuddin
Created December 22, 2010 22:51
Show Gist options
  • Save brettbuddin/752234 to your computer and use it in GitHub Desktop.
Save brettbuddin/752234 to your computer and use it in GitHub Desktop.
Quick web server from Rake
task :server do
require 'webrick'
include WEBrick
def start_webrick(config = {})
config.update(:Port => 3000)
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 => File.dirname(__FILE__))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment