forked from erp-dev/erp
fix: added pgBouncer for conn pool manage
This commit is contained in:
@@ -15,6 +15,38 @@ services:
|
||||
- db_data:/var/lib/postgresql/data
|
||||
restart: unless-stopped
|
||||
|
||||
pgbouncer:
|
||||
image: pgbouncer/pgbouncer:latest
|
||||
container_name: pgbouncer
|
||||
environment:
|
||||
POSTGRES_HOST: postgres
|
||||
POSTGRES_PORT: "${POSTGRES_PORT:-5432}"
|
||||
POSTGRES_DB: ${POSTGRES_DB:-flower}
|
||||
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
|
||||
DATABASES_HOST: postgres
|
||||
DATABASES_PORT: "${POSTGRES_PORT:-5432}"
|
||||
DATABASES_USER: ${POSTGRES_USER:-postgres}
|
||||
DATABASES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
|
||||
DATABASES_DBNAME: ${POSTGRES_DB:-flower}
|
||||
PGBOUNCER_POOL_MODE: transaction
|
||||
PGBOUNCER_MAX_CLIENT_CONN: "100"
|
||||
PGBOUNCER_DEFAULT_POOL_SIZE: "25"
|
||||
PGBOUNCER_MIN_POOL_SIZE: "5"
|
||||
PGBOUNCER_RESERVE_POOL_SIZE: "5"
|
||||
PGBOUNCER_RESERVE_POOL_TIMEOUT: "3"
|
||||
PGBOUNCER_SERVER_IDLE_TIMEOUT: "600"
|
||||
PGBOUNCER_LOG_CONNECTIONS: "1"
|
||||
PGBOUNCER_LOG_DISCONNECTIONS: "1"
|
||||
PGBOUNCER_LOG_POOLER_ERRORS: "1"
|
||||
ports:
|
||||
- "${PGBOUNCER_PORT:-6432}:6432"
|
||||
volumes:
|
||||
- ./pgbouncer/pgbouncer.ini:/etc/pgbouncer/pgbouncer.ini:ro
|
||||
depends_on:
|
||||
- postgres
|
||||
restart: unless-stopped
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: redis
|
||||
@@ -51,14 +83,15 @@ services:
|
||||
PYTHONPATH: /app
|
||||
DEBUG: "${DEBUG:-0}"
|
||||
ALLOWED_HOSTS: "${ALLOWED_HOSTS:-yuwenerp.yuwen.cloud}"
|
||||
DB_HOST: ${DB_HOST:-postgres}
|
||||
DB_PORT: "${DB_PORT:-5432}"
|
||||
DB_HOST: ${DB_HOST:-pgbouncer}
|
||||
DB_PORT: "${DB_PORT:-6432}"
|
||||
DB_NAME: "${DB_NAME:-flower}"
|
||||
DB_USER: "${DB_USER:-postgres}"
|
||||
DB_PASSWORD: "${DB_PASSWORD:-postgres}"
|
||||
CELERY_BROKER_URL: "${CELERY_BROKER_URL:-amqp://guest:guest@rabbitmq:5672//}"
|
||||
CELERY_RESULT_BACKEND: "${CELERY_RESULT_BACKEND:-redis://redis:6379/0}"
|
||||
depends_on:
|
||||
- pgbouncer
|
||||
- postgres
|
||||
- redis
|
||||
- rabbitmq
|
||||
@@ -78,8 +111,8 @@ services:
|
||||
- --pool=solo
|
||||
environment:
|
||||
PYTHONPATH: /app
|
||||
DB_HOST: ${DB_HOST:-postgres}
|
||||
DB_PORT: "${DB_PORT:-5432}"
|
||||
DB_HOST: ${DB_HOST:-pgbouncer}
|
||||
DB_PORT: "${DB_PORT:-6432}"
|
||||
DB_NAME: "${DB_NAME:-flower}"
|
||||
DB_USER: "${DB_USER:-postgres}"
|
||||
DB_PASSWORD: "${DB_PASSWORD:-postgres}"
|
||||
@@ -91,6 +124,7 @@ services:
|
||||
# 也可通过 BACKUP_DIR 指定绝对路径,如 /srv/flower/data-bak
|
||||
- ${BACKUP_DIR:-./data-bak}:/app/data-bak
|
||||
depends_on:
|
||||
- pgbouncer
|
||||
- postgres
|
||||
- redis
|
||||
- rabbitmq
|
||||
@@ -111,8 +145,8 @@ services:
|
||||
environment:
|
||||
DJANGO_SETTINGS_MODULE: flower.settings
|
||||
PYTHONPATH: /app
|
||||
DB_HOST: ${DB_HOST:-postgres}
|
||||
DB_PORT: "${DB_PORT:-5432}"
|
||||
DB_HOST: ${DB_HOST:-pgbouncer}
|
||||
DB_PORT: "${DB_PORT:-6432}"
|
||||
DB_NAME: "${DB_NAME:-flower}"
|
||||
DB_USER: "${DB_USER:-postgres}"
|
||||
DB_PASSWORD: "${DB_PASSWORD:-postgres}"
|
||||
@@ -122,6 +156,7 @@ services:
|
||||
volumes:
|
||||
- celery_beat_data:/var/lib/celery
|
||||
depends_on:
|
||||
- pgbouncer
|
||||
- postgres
|
||||
- redis
|
||||
- rabbitmq
|
||||
|
||||
Reference in New Issue
Block a user