Rails 4自定义404导致Heroku上的postgresql连接失败

我在生产中使用自定义域部署了一个Rails 4应用程序。 我也有一个升级版本。 该应用程序使用舒适的墨西哥沙发。

出现以下问题:应用程序将达到所有请求返回500错误的状态。 日志显示:

[jesse@Athens expat]$ heroku logs ActiveRecord::ConnectionTimeoutError (could not obtain a database connection within 5.000 seconds (waited 5.000 seconds)): [jesse@Athens expat]$ heroku pg:info Connections: 5 [jesse@Athens expat]$ heroku pg:ps pid | state | source | running_for | waiting | query -----+-------+--------+-------------+---------+------- (0 rows) [jesse@Athens expat]$ heroku pg:killall pg_terminate_backend ---------------------- t t t t t (5 rows) 

连接尝试连接导致500错误和数据库连接保持为0。

使用本指南创建自定义错误页面后出现此问题: http : //wearestac.com/blog/dynamic-error-pages-in-rails 。

我可以通过创建一个404页面来强制解决这个问题,该页面使用数据库,然后向服务器发出大约5或6个请求,以获取不存在的页面。

编辑:

我可以在使用静态自定义404页面时强制解决问题,方法是对带有jpeg扩展名的不存在文件发出5或6个请求。 日志中显示以下内容:

 Error during failsafe response: Missing template errors/not_found, application/not_found with {:locale=>[:en], :formats=>[:jpeg], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee, :haml]}. Searched in: 2014-02-17T17:26:14.595469+00:00 app[web.1]: * "/app/app/vi ews" 2014-02-17T17:26:14.594508+00:00 app[web.1]: Completed 500 Internal Server Error in 7ms 

任何帮助隔离这个问题将不胜感激。 提前致谢

这是function控制器代码:

 class ErrorsController < ApplicationController def not_found respond_to do |format| format.any(:htm, :html, :xls, :xlsx) { render :status => 404, :layout => "error_frame", :formats => [:html] } format.all { render nothing: true, status: 404 } end end def unacceptable respond_to do |format| format.html { render :status => 422, :layout => "error_frame" } format.all { render nothing: true, status: 422 } end end def internal_error respond_to do |format| format.html { render :layout => false, :status => 500 } format.all { render nothing: true, status: 500} end end end 
Interesting Posts