Created
July 18, 2011 21:54
-
-
Save shokai/1090762 to your computer and use it in GitHub Desktop.
httpd.rb
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'webrick' | |
port = 8080 | |
port = ARGV.first.to_i unless ARGV.empty? | |
#document_root = ENV['HOME'] | |
document_root = './' | |
server = WEBrick::HTTPServer.new({ | |
:DocumentRoot => document_root, | |
:BindAddress => '0.0.0.0', | |
:Port => port | |
}) | |
['INT', 'TERM'].each {|signal| | |
Signal.trap(signal){ server.shutdown } | |
} | |
server.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment