require 'webrick'
include WEBrick
if ARGV.length == 1
s = HTTPServer.new(:Port => ARGV[0], :DocumentRoot => Dir::pwd)
trap ("INT", proc{s.shutdown})
s.start
else
puts "Usage: ruby webserver.rb port"
end
For some reason, alot of the sources I found online didnt mention calling the proc function with the shutdown block. Without this, I was getting a segfault in the Ruby shipped with Ubuntu 5.10. Go figure. Maybe some day I'll be knowledgable enough to track down whats going on?
No comments:
Post a Comment