加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-13 18:04:28 所属栏目:百科 来源:网络整理
导读:我正在使用带有Rails 4.1.1和 Ruby 2.1.1的heroku.我正在使用heroku的默认数据库配置.这就是我将database.yml放入.gitignore并且我没有使用database.yml进行生产的原因. 我面临着PG :: ConnectionBad的问题:PQsocket()无法获取套接字描述符,为了解决这个错
我正在使用带有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)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读