使用rails 4.1& 4.1.0rc2
我们在渲染方面遇到了这个奇怪的问题:
I, [2014-04-13T07:45:28.856574 #5695] INFO -- : Started GET "/xpto" for xxx.xxx.xxx.xxx at 2014-04-13 07:45:28 +0000
I, [2014-04-13T07:45:28.916947 #5695] INFO -- : Processing by XptoController#index as HTML
D, [2014-04-13T07:45:28.952666 #5695] DEBUG -- : Cart Load (2.5ms) sql
D, [2014-04-13T07:45:29.000582 #5695] DEBUG -- : SQL (2.5ms) sql
D, [2014-04-13T07:45:29.004601 #5695] DEBUG -- : SQL (2.6ms) sql
I, [2014-04-13T07:45:29.026042 #5695] INFO -- : Rendered xpto/index.html.erb within layouts/application (58.4ms)
I, [2014-04-13T07:45:29.719445 #5695] INFO -- : Completed 200 OK in 802ms (Views: 735.2ms | ActiveRecord: 31.4ms)
正如您在日志中所看到的,渲染采用了58.4ms
,但是" View"花了735.2ms
。每个数据都被预加载,视图仅包含:
<h1>xptos</h1>
<% @xptos.each do |xpto| %>
<p>link: <%= link_to xpto.name, xptos_path(xpto) %> (ID: <%= xpto.id %>)</p>
<% end %>
使用的配置:
Rails.application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = true
config.assets.js_compressor = :uglifier
config.assets.compile = false
config.assets.digest = true
config.assets.version = '1.0'
config.force_ssl = false
config.log_level = :debug
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
config.paperclip_defaults = {
storage: :fog,
fog_credentials: { provider: 'aws',
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
},
fog_directory: 'xpto-bucket'
}
end
Unicorn直接通过config:
提供请求log_path = 'log/unicorn.log'
pid_path = 'tmp/pids/unicorn.pid'
pid pid_path
worker_processes 8
timeout 15
preload_app true
listen 3000, backlog: 1025
stderr_path log_path
stdout_path log_path
before_fork do |server, worker|
ActiveRecord::Base.connection.disconnect! if defined?(ActiveRecord)
end
after_fork do |server, worker|
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
end
有没有办法在渲染之后但在返回响应之前调试花了这么长时间?