Added --server option to start a simple WEBrick server on destination directory

This commit is contained in:
John Reilly 2008-12-19 17:49:57 -06:00
parent ed60ad6f72
commit 9ecbfb2253
1 changed files with 22 additions and 0 deletions

View File

@ -25,6 +25,10 @@ opts = OptionParser.new do |opts|
options[:auto] = true
end
opts.on("--server", "Run a WEBrick server on destination directory") do
options[:server] = true
end
opts.on("--lsi", "Use LSI for better related posts") do
Jekyll.lsi = true
end
@ -78,6 +82,24 @@ case ARGV.size
exit(1)
end
if options[:server]
require 'webrick'
include WEBrick
s = HTTPServer.new(
:Port => 4000,
:DocumentRoot => destination
)
t = Thread.new {
s.start
}
unless options[:auto]
trap("INT") { s.shutdown }
t.join()
end
end
if options[:auto]
require 'directory_watcher'