docker - 如何使用daphne在heroku.yml中运行pgBouncer

标签 docker heroku pgbouncer daphne

因此,我构建了一个聊天应用程序并将其与heroku一起部署。由于我在hobby-dev上,所以我只能与Postgres建立20个连接,因此,根据一些在线建议,我决定使用pgbouncer可能是个好主意。关于设置构建包的heroku文档(例如https://devcenter.heroku.com/articles/python-concurrency-and-database-connections#number-of-active-connections的最后一部分)是有限的,我发现的所有内容都要求我更改Procfile中的某些内容。问题是我使用的是docker容器,因此最终使用heroku.yml和daphne命令运行该程序。在网络中直接添加bin/start-pgbouncer只会导致整个应用程序失败。

这是我当前的运行命令

run:
  web: daphne test_project.asgi:application --port $PORT --bind 0.0.0.0 -v2

我试过了
run:
  web: bin/start-pgbouncer-stunnel daphne test_project.asgi:application --port $PORT --bind 0.0.0.0 -v2



run:
  web: start-pgbouncer-stunnel daphne test_project.asgi:application --port $PORT --bind 0.0.0.0 -v2


都失败了。我还在heroku日志中发现heroku似乎会自动将/bin/sh -c附加到我的运行命令中(例如/bin/sh -c daphne\ test_project.asgi:application\ --port\ \53166\ --bind\ 0.0.0.0\ -v2)。

这可能引起问题吗?我应该在网络中放置什么以与我的应用程序一起运行pg-bouncer?

最佳答案

最简单的解决方案是创建一个bash脚本run.sh

set -ev

service pgbouncer start
daphne test_project.asgi:application --port $PORT --bind 0.0.0.0 -v2
service pgbouncer stop

run:
  web: run.sh

关于docker - 如何使用daphne在heroku.yml中运行pgBouncer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59999516/

相关文章:

Git 错误 : Permission to user1/repoA. git 拒绝 user2

django 1.7 和连接池到 PostgreSQL?

linux - 多个端口上的 pgBouncer?

PCF中的Docker - 无法通过AMQP(spring cloud bus)连接到rabbitmq

docker - 使用Supervisor启动Filebeat

java - Heroku mvn 找不到错误

PostgreSQL:heroku 数据库服务器上的 array_agg() 内存不足问题

java - 无法在 Kubernetes 上加载 Logstash 配置文件

docker - 带有用户 namespace 映射的Docker构建和docker-compose构建

ruby-on-rails - 在 Rails 中禁用连接池以使用 PgBouncer