我有一个Rails 4应用程序,已经部署在Heroku上作为生产环境,并使用自定义域名。我还有一个staging版本。该应用程序使用Comfortable Mexican Sofa。
出现以下问题:应用程序将达到一种状态,其中所有请求都会返回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页面并发出5或6个对具有jpeg扩展名的不存在文件的请求来强制出现问题。日志中出现以下内容:
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
任何帮助解决这个问题都将不胜感激。提前致谢。