postgresql – 如何在heroku的database.yml中覆盖pool和reaping_frequency

前端之家收集整理的这篇文章主要介绍了postgresql – 如何在heroku的database.yml中覆盖pool和reaping_frequency前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用带有Rails 4.1.1和 Ruby 2.1.1的heroku.我正在使用heroku的默认数据库配置.这就是我将database.yml放入.gitignore并且我没有使用database.yml进行生产的原因.

我面临着PG :: ConnectionBad的问题:PQsocket()无法获取套接字描述符,为了解决这个错误我需要设置reaping_frequency.

The reaping_frequency can tell Active Record to check to see if connections are hung or dead every N seconds and terminate them. While it is likely that over time your application may have a few connections that hang,if something in your code is causing hung connections,the reaper will not be a permanent fix to the problem.

现在我想将此配置添加到database.yml中.

reaping_frequency: 10

所以我应该直接在database.yml上添加此配置以进行覆盖,还是有其他更好的方法将此频率设置为heroku?

提前感谢您的建议.

在配置中的config / unicorn.rb或config / puma.rb中设置池和reaping_frequency:
config = ActiveRecord::Base.configurations[Rails.env] ||
            Rails.application.config.database_configuration[Rails.env]
config['pool']              = ENV['DB_POOL'] || 5
config['reaping_frequency'] = ENV['DB_REAP_FREQ'] || 10 # seconds
ActiveRecord::Base.establish_connection(config)

猜你在找的Postgre SQL相关文章