module Middleman::PreviewServer

def setup_webrick(host, is_logging)

Returns:
  • (void) -
def setup_webrick(host, is_logging)
  @host = host
  http_opts = {
    :BindAddress => @host,
    :Port        => port,
    :AccessLog   => []
  }
  if is_logging
    http_opts[:Logger] = FilteredWebrickLog.new
  else
    http_opts[:Logger] = ::WEBrick::Log.new(nil, 0)
  end
  begin
    ::WEBrick::HTTPServer.new(http_opts)
  rescue Errno::EADDRINUSE => e
    logger.error "== Port #{port} is unavailable. Either close the instance of Middleman already running on #{port} or start this Middleman on a new port with: --port=#{port.to_i+1}"
    exit(1)
  end
end