Created
December 22, 2010 22:51
-
-
Save brettbuddin/752234 to your computer and use it in GitHub Desktop.
Quick web server from Rake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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