ruby-on-rails - Heroku Rails 6 multiple connection not working
问题描述
I have a project running on Rails 6 with multiple database configuration.
This is my database.yml configuration
default: &default
adapter: postgresql
encoding: unicode
# # For details on connection pooling, see Rails configuration guide
# # https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS")%>
bn: &bn
adapter: postgresql
database: <%= ENV.fetch('DB_NAME_BN')%>
default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS")%>
timeout: 5000
development:
primary:
<<: *default
database: <%= ENV.fetch("DB_NAME")%>
bn:
<<: *bn
production:
primary:
url: <%= ENV.fetch('DATABASE_URL') %>
bn:
url: <%= ENV.fetch('DB_NAME_BN')%>
This configuration is correctly working in development, however, when deploying it to Heroku the app crashes.
The error looks like this:
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
bundler: failed to load command: puma (/app/vendor/bundle/ruby/2.6.0/bin/puma)
Seems like rails is not considering the 3-tier configuration so assumes a local server. I've been trying to configure the file in several ways, none of them work in Heroku. I followed the puma.rb configuration suggested in Heroku but it does not make any difference.
Any thoughts on how I could fix this issue? Is it a Rails issue or a PgAdapter issue?
The relevant part of my Gemfile is
ruby '2.6.3'
gem 'rails', '~> 6.0.0'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 3.11'
解决方案
推荐阅读
- notepad++ - 仅为 Notepad++ 上的 .txt 文件更改字体颜色
- javascript - 未定义的 ES6 属性值简写
- python - 页面加载时Django Channels ws url未连接
- node.js - NPM - 依赖项需要多个版本的包,但只安装了一个版本
- javascript - javascript中拖放时弹出窗口
- php - Wordpress - 当他进入主页时强制注销用户
- c# - c# 从列表框中搜索文本框
- excel - 恢复excel csv中丢失的公式
- ms-access - 循环使用名称类似于示例的查询
- kubernetes - 如何诊断 Kuberentes 上的“错误同步 pod”pod?