Add timing info to render logging, and document why we use thin instead of webrick
This commit is contained in:
parent
9024de85d8
commit
c560a0d20e
|
@ -378,6 +378,8 @@ module Middleman
|
|||
#
|
||||
# @private
|
||||
def process_request
|
||||
start_time = Time.now
|
||||
|
||||
# Normalize the path and add index if we're looking at a directory
|
||||
@original_path = env["PATH_INFO"].dup
|
||||
@escaped_path = @original_path.gsub("%20", " ")
|
||||
|
@ -418,7 +420,7 @@ module Middleman
|
|||
end
|
||||
|
||||
# End the request
|
||||
puts "== Finishing Request: #{self.current_path}" if logging?
|
||||
puts "== Finishing Request: #{self.current_path} (#{(Time.now - start_time).round(2)}s)" if logging?
|
||||
halt res.finish
|
||||
end
|
||||
|
||||
|
@ -531,28 +533,25 @@ module Middleman
|
|||
# @param [Hash] options to pass to Rack::Server.new
|
||||
# @return [Rack::Server]
|
||||
def start_server(options={})
|
||||
require "webrick"
|
||||
|
||||
opts = {
|
||||
:Port => options[:port] || 4567,
|
||||
:Host => options[:host] || "0.0.0.0",
|
||||
:AccessLog => []
|
||||
}
|
||||
|
||||
# opts[:Logger] = WEBrick::Log::new("/dev/null", 7) if !options[:logging]
|
||||
|
||||
app_class = options[:app] ||= ::Middleman.server.inst
|
||||
opts[:app] = app_class
|
||||
|
||||
# Disable for Beta 1. See if people notice.
|
||||
# Use Thin because Webrick gets confused and mixes
|
||||
# up responses.
|
||||
# TODO: Figure that out and drop Thin dependency
|
||||
require "thin"
|
||||
::Thin::Logging.silent = !options[:logging]
|
||||
opts[:server] = 'thin'
|
||||
# opts[:server] = 'webrick'
|
||||
|
||||
server = ::Rack::Server.new(opts)
|
||||
server.start
|
||||
server
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -88,6 +88,7 @@ module Middleman::Sitemap
|
|||
def render(opts={}, locs={}, &block)
|
||||
return File.open(source_file).read unless template?
|
||||
|
||||
start_time = Time.now
|
||||
puts "== Render Start: #{source_file}" if app.logging?
|
||||
|
||||
md = metadata.dup
|
||||
|
@ -106,7 +107,7 @@ module Middleman::Sitemap
|
|||
app.instance_eval(&block) if block_given?
|
||||
result = app.render_template(source_file, locs, opts)
|
||||
|
||||
puts "== Render End: #{source_file}" if app.logging?
|
||||
puts "== Render End: #{source_file} (#{(Time.now - start_time).round(2)}s)" if app.logging?
|
||||
result
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue