如何增加 github 操作 Postgres 中的 max_connection

xxk*_*kkk 6 postgresql github-actions

我想max_connections在github上增加Postgres服务的action。官方文档没有提及如何操作。有一些巧妙的技巧吗?

我尝试了这个 SO 答案,它似乎在 github 操作环境中不起作用。

Gaj*_*jus 0

有一个简单的方法可以做到这一点,但是您可以通过安装 pg 客户端并在服务启动时配置容器来实现。确切的步骤记录在这篇博客文章中。

相关代码:

steps:
  - name: Install postgresql-client
    run: |
      sudo apt-get update
      sudo apt-get install --yes postgresql-client

  - name: Connect to PostgreSQL with CLI
    run: psql -c 'SELECT VERSION();'

  - name: Show PostgreSQL config file
    run: psql -c 'SHOW config_file;'

  - name: Alter max connections
    run: |
      docker exec -i postgres bash << EOF
        sed -i -e 's/max_connections = 100/max_connections = 1000/' /var/lib/postgresql/data/postgresql.conf
        sed -i -e 's/shared_buffers = 128MB/shared_buffers = 2GB/' /var/lib/postgresql/data/postgresql.conf
      EOF
      docker restart --time 0 postgres
      sleep 5

  - name: Show max connections
    run: psql -c 'SHOW max_connections;'
Run Code Online (Sandbox Code Playgroud)

由于没有为 Docker 服务设置自定义命令的选项,这仍然是最直接的方法。