Wrapper class around the webrick web server.
Join on the webserver thread.
# File lib/webby/auto_builder.rb, line 147 def join return if not running? @thread.join end
Returns true
if the server is running.
# File lib/webby/auto_builder.rb, line 124 def running? @running end
Start the webrick server running in a separate thread (so we don’t block forever).
# File lib/webby/auto_builder.rb, line 131 def start return if running? @running = true @thread = Thread.new {@server.start} end
Stop the webrick server.
# File lib/webby/auto_builder.rb, line 139 def stop return if not running? @running = false @server.shutdown end
Create a new webrick server configured to serve pages from the output directory. Output will be directed to /dev/null.
# File lib/webby/auto_builder.rb, line 106 def initialize logger = WEBrick::Log.new(Kernel::DEV_NULL, WEBrick::Log::DEBUG) access_log = [[ logger, WEBrick::AccessLog::COMBINED_LOG_FORMAT ]] @thread = nil @running = false @server = WEBrick::HTTPServer.new( :BindAddress => 'localhost', :Port => ::Webby.site.web_port, :DocumentRoot => ::Webby.site.output_dir, :FancyIndexing => true, :Logger => logger, :AccessLog => access_log ) end