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
|
# @private
|
||||||
def process_request
|
def process_request
|
||||||
|
start_time = Time.now
|
||||||
|
|
||||||
# Normalize the path and add index if we're looking at a directory
|
# Normalize the path and add index if we're looking at a directory
|
||||||
@original_path = env["PATH_INFO"].dup
|
@original_path = env["PATH_INFO"].dup
|
||||||
@escaped_path = @original_path.gsub("%20", " ")
|
@escaped_path = @original_path.gsub("%20", " ")
|
||||||
|
@ -418,7 +420,7 @@ module Middleman
|
||||||
end
|
end
|
||||||
|
|
||||||
# End the request
|
# 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
|
halt res.finish
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -531,28 +533,25 @@ module Middleman
|
||||||
# @param [Hash] options to pass to Rack::Server.new
|
# @param [Hash] options to pass to Rack::Server.new
|
||||||
# @return [Rack::Server]
|
# @return [Rack::Server]
|
||||||
def start_server(options={})
|
def start_server(options={})
|
||||||
require "webrick"
|
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
:Port => options[:port] || 4567,
|
:Port => options[:port] || 4567,
|
||||||
:Host => options[:host] || "0.0.0.0",
|
:Host => options[:host] || "0.0.0.0",
|
||||||
:AccessLog => []
|
:AccessLog => []
|
||||||
}
|
}
|
||||||
|
|
||||||
# opts[:Logger] = WEBrick::Log::new("/dev/null", 7) if !options[:logging]
|
|
||||||
|
|
||||||
app_class = options[:app] ||= ::Middleman.server.inst
|
app_class = options[:app] ||= ::Middleman.server.inst
|
||||||
opts[:app] = app_class
|
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"
|
require "thin"
|
||||||
::Thin::Logging.silent = !options[:logging]
|
::Thin::Logging.silent = !options[:logging]
|
||||||
opts[:server] = 'thin'
|
opts[:server] = 'thin'
|
||||||
# opts[:server] = 'webrick'
|
|
||||||
|
|
||||||
server = ::Rack::Server.new(opts)
|
server = ::Rack::Server.new(opts)
|
||||||
server.start
|
server.start
|
||||||
server
|
server
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -88,6 +88,7 @@ module Middleman::Sitemap
|
||||||
def render(opts={}, locs={}, &block)
|
def render(opts={}, locs={}, &block)
|
||||||
return File.open(source_file).read unless template?
|
return File.open(source_file).read unless template?
|
||||||
|
|
||||||
|
start_time = Time.now
|
||||||
puts "== Render Start: #{source_file}" if app.logging?
|
puts "== Render Start: #{source_file}" if app.logging?
|
||||||
|
|
||||||
md = metadata.dup
|
md = metadata.dup
|
||||||
|
@ -106,7 +107,7 @@ module Middleman::Sitemap
|
||||||
app.instance_eval(&block) if block_given?
|
app.instance_eval(&block) if block_given?
|
||||||
result = app.render_template(source_file, locs, opts)
|
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
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue