Rails 4 - 故障安全响应期间出错:未定义的方法'验证'为零:NilClass

时间:2014-11-07 14:38:48

标签: authentication ruby-on-rails-4 devise warden

我们在webrick服务器上的生产环境中有一个rails 4应用程序,它会定期崩溃并返回500错误。 崩溃似乎来自以下错误:

Error during failsafe response: undefined method `authenticate' for nil:NilClass
      /usr/local/rvm/gems/ruby-2.1.2/gems/devise-3.2.2/lib/devise/controllers/helpers.rb:58:in `current_user'

我们在第58行检查了helpers.rb文件,因此它来自于'current_user'方法中对wardent.authenticate的调用。所以我们在Gemfile中导入了gem'warden',但没有任何变化。

我们还尝试将webrick服务器更改为“puma”服务器,认为它可能来自线程,但没有任何改变......

整个错误如下:

Error during failsafe response: undefined method `authenticate' for nil:NilClass
  /usr/local/rvm/gems/ruby-2.1.2/gems/devise-3.2.2/lib/devise/controllers/helpers.rb:58:in `current_user'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/helpers.rb:53:in `current_user'
  /home/dev/myProject/app/views/shared/_top_menu.html.erb:23:in `_app_views_shared__top_menu_html_erb___3475115451092967008_67265400'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/template.rb:143:in `block in render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications.rb:161:in `instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/template.rb:141:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/partial_renderer.rb:306:in `render_partial'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/partial_renderer.rb:279:in `block in render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications.rb:159:in `block in instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications.rb:159:in `instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/partial_renderer.rb:278:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/renderer.rb:47:in `render_partial'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/helpers/rendering_helper.rb:27:in `render'
  /home/dev/myProject/app/views/layouts/application.html.erb:18:in `_app_views_layouts_application_html_erb__2013404122424653986_65265180'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/template.rb:143:in `block in render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications.rb:161:in `instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/template.rb:141:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/template_renderer.rb:47:in `render_template'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/template_renderer.rb:17:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/renderer.rb:42:in `render_template'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/renderer.rb:23:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/rendering.rb:127:in `_render_template'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/streaming.rb:219:in `_render_template'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/rendering.rb:120:in `render_to_body'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/rendering.rb:33:in `render_to_body'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/renderers.rb:26:in `render_to_body'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/rendering.rb:97:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/rendering.rb:16:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
  /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/core_ext/benchmark.rb:12:in `ms'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/instrumentation.rb:41:in `block in render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activerecord-4.0.11/lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/instrumentation.rb:40:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/base.rb:189:in `process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/rendering.rb:10:in `process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/callbacks.rb:403:in `_run__2818342425517875908__process_action__callbacks'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/callbacks.rb:80:in `run_callbacks'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/callbacks.rb:17:in `process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/rescue.rb:29:in `process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications.rb:159:in `block in instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications.rb:159:in `instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activerecord-4.0.11/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/base.rb:136:in `process'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/rendering.rb:44:in `process'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal.rb:195:in `dispatch'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal.rb:231:in `block in action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/routing/route_set.rb:82:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/routing/route_set.rb:50:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/journey/router.rb:71:in `block in call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/journey/router.rb:59:in `each'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/journey/router.rb:59:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/routing/route_set.rb:676:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/middleware/show_exceptions.rb:43:in `render_exception'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/middleware/show_exceptions.rb:33:in `rescue in call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.0.11/lib/rails/rack/logger.rb:38:in `call_app'
  /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.0.11/lib/rails/rack/logger.rb:20:in `block in call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/tagged_logging.rb:68:in `block in tagged'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/tagged_logging.rb:26:in `tagged'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/tagged_logging.rb:68:in `tagged'
  /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.0.11/lib/rails/rack/logger.rb:20:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/middleware/request_id.rb:21:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/cache/strategy/local_cache.rb:83:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/middleware/static.rb:84:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.0.11/lib/rails/engine.rb:511:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.0.11/lib/rails/application.rb:97:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
  /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
  /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
  /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
Error during failsafe response: undefined method `authenticate' for nil:NilClass
  /usr/local/rvm/gems/ruby-2.1.2/gems/devise-3.2.2/lib/devise/controllers/helpers.rb:58:in `current_user'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/helpers.rb:53:in `current_user'
  /home/dev/myProject/app/views/shared/_top_menu.html.erb:23:in `_app_views_shared__top_menu_html_erb___3475115451092967008_68619440'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/template.rb:143:in `block in render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications.rb:161:in `instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/template.rb:141:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/partial_renderer.rb:306:in `render_partial'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/partial_renderer.rb:279:in `block in render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications.rb:159:in `block in instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications.rb:159:in `instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/partial_renderer.rb:278:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/renderer.rb:47:in `render_partial'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/helpers/rendering_helper.rb:27:in `render'
  /home/dev/myProject/app/views/layouts/application.html.erb:18:in `_app_views_layouts_application_html_erb__2013404122424653986_65265180'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/template.rb:143:in `block in render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications.rb:161:in `instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/template.rb:141:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/template_renderer.rb:47:in `render_template'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/template_renderer.rb:17:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/renderer.rb:42:in `render_template'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/renderer.rb:23:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/rendering.rb:127:in `_render_template'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/streaming.rb:219:in `_render_template'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/rendering.rb:120:in `render_to_body'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/rendering.rb:33:in `render_to_body'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/renderers.rb:26:in `render_to_body'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/rendering.rb:97:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/rendering.rb:16:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
  /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/core_ext/benchmark.rb:12:in `ms'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/instrumentation.rb:41:in `block in render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activerecord-4.0.11/lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/instrumentation.rb:40:in `render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/base.rb:189:in `process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/rendering.rb:10:in `process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/callbacks.rb:403:in `_run__2818342425517875908__process_action__callbacks'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/callbacks.rb:80:in `run_callbacks'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/callbacks.rb:17:in `process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/rescue.rb:29:in `process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications.rb:159:in `block in instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications.rb:159:in `instrument'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activerecord-4.0.11/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/base.rb:136:in `process'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/rendering.rb:44:in `process'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal.rb:195:in `dispatch'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_controller/metal.rb:231:in `block in action'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/routing/route_set.rb:82:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/routing/route_set.rb:50:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/journey/router.rb:71:in `block in call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/journey/router.rb:59:in `each'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/journey/router.rb:59:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/routing/route_set.rb:676:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/middleware/show_exceptions.rb:43:in `render_exception'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/middleware/show_exceptions.rb:33:in `rescue in call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.0.11/lib/rails/rack/logger.rb:38:in `call_app'
  /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.0.11/lib/rails/rack/logger.rb:20:in `block in call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/tagged_logging.rb:68:in `block in tagged'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/tagged_logging.rb:26:in `tagged'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/tagged_logging.rb:68:in `tagged'
  /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.0.11/lib/rails/rack/logger.rb:20:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/middleware/request_id.rb:21:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/cache/strategy/local_cache.rb:83:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_dispatch/middleware/static.rb:84:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.0.11/lib/rails/engine.rb:511:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.0.11/lib/rails/application.rb:97:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
  /usr/local/rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
  /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
  /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
  /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
[2014-11-07 13:06:52] FATAL SignalException: SIGTERM
    /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:170:in `select'
    /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:170:in `block in start'
    /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:32:in `start'
    /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:160:in `start'
    /usr/local/rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/handler/webrick.rb:14:in `run'
    /usr/local/rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
    /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.0.11/lib/rails/commands/server.rb:84:in `start'
    /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.0.11/lib/rails/commands.rb:76:in `block in <top (required)>'
    /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.0.11/lib/rails/commands.rb:71:in `tap'
    /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.0.11/lib/rails/commands.rb:71:in `<top (required)>'
    bin/rails:4:in `require'
    bin/rails:4:in `<main>'
[2014-11-07 13:06:52] INFO  going to shutdown ...
[2014-11-07 13:06:52] INFO  WEBrick::HTTPServer#start done.
Processing by ErrorsController#internal_server_error as HTML
  Rendered errors/internal_server_error.html.erb within layouts/application (0.3ms)
  Rendered shared/_top_menu.html.erb (1.4ms)
Completed 500 Internal Server Error in 3ms

有没有人知道它可能来自哪里?

更新

在本文中详细说明错误之前发生了其他错误,这里是错误:

    ActiveRecord::ConnectionTimeoutError (could not obtain a database connection within 5.000 seconds (waited 5.000 seconds)):
  activerecord (4.0.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `block in wait_poll'
  activerecord (4.0.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in `loop'
  activerecord (4.0.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in `wait_poll'
  activerecord (4.0.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:136:in `block in poll'
  /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
  activerecord (4.0.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:146:in `synchronize'
  activerecord (4.0.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:134:in `poll'
  activerecord (4.0.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:423:in `acquire_connection'
  activerecord (4.0.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `block in checkout'
  /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
  activerecord (4.0.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
  activerecord (4.0.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
  /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
  activerecord (4.0.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
  activerecord (4.0.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'
  activerecord (4.0.11) lib/active_record/connection_handling.rb:79:in `retrieve_connection'
  activerecord (4.0.11) lib/active_record/connection_handling.rb:53:in `connection'
  activerecord (4.0.11) lib/active_record/query_cache.rb:51:in `restore_query_cache_settings'
  activerecord (4.0.11) lib/active_record/query_cache.rb:43:in `rescue in call'
  activerecord (4.0.11) lib/active_record/query_cache.rb:32:in `call'
  activerecord (4.0.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
  actionpack (4.0.11) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.0.11) lib/active_support/callbacks.rb:373:in `_run__2890043484802466369__call__callbacks'
  activesupport (4.0.11) lib/active_support/callbacks.rb:80:in `run_callbacks'
  actionpack (4.0.11) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.0.11) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
  actionpack (4.0.11) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  actionpack (4.0.11) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.0.11) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.0.11) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.0.11) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.0.11) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.0.11) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.0.11) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.0.11) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  activesupport (4.0.11) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
  actionpack (4.0.11) lib/action_dispatch/middleware/static.rb:84:in `call'
  rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
  railties (4.0.11) lib/rails/engine.rb:511:in `call'
  railties (4.0.11) lib/rails/application.rb:97:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  rack (1.5.2) lib/rack/content_length.rb:14:in `call'
  rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
  /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
  /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
  /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'

更新2

我已经将'puma'gem添加到Gemfile中以启用puma多线程服务器,并添加了以下config / initializers / database_connection.rb:

Rails.application.config.after_initialize do
  ActiveRecord::Base.connection_pool.disconnect!

  ActiveSupport.on_load(:active_record) do
    config = ActiveRecord::Base.configurations[Rails.env] ||
                Rails.application.config.database_configuration[Rails.env]
    config['pool']              = ENV['DB_POOL']      || ENV['MAX_THREADS'] || 5
    ActiveRecord::Base.establish_connection(config)
  end
end

但错误仍然存​​在......

解决方案!

我们已经部署了一个带有Capistrano和Phusion Passenger的Apache服务器。从那时起,一切运行良好,没有Rails,或设计或其他任何问题。我认为问题是我们相信默认的Webrick服务器在生产环境中工作,而它只适用于开发环境......

感谢所有人的帮助和建议

3 个答案:

答案 0 :(得分:4)

作为从Google发现此错误的人的后续跟进。如果使用Devise,则无法正确初始化时会发生此错误。如果您查看日志,可能会在启动时发现另一个错误,即阻止Devise初始化。在这种情况下,堆栈跟踪是无关紧要的。

就我而言,根本问题是我有待处理的迁移。

答案 1 :(得分:1)

安装了Apache Server + Phusion Passenger + Capistrano,并为生产部署配置了所有环境后,一切似乎都运行良好。 (对于生产环境而言,只有一个webrick服务器是有效的,即使对于测试版也是如此)

感谢所有帮助我们并回答我们问题的人。

答案 2 :(得分:0)

我的类似问题是因为我试图捕获404错误但是我的图像有错误的映射,并且总是落入错误页面,直到锁定我的项目。然后我也遇到了这个问题:

ActiveRecord::ConnectionTimeoutError (could not obtain a database connection within 5.000 seconds (waited 5.000 seconds))

解决方案是修复映射和任何其他类似的重复错误。