From 5dd89d362107b1b7de218671269021bb04d50c03 Mon Sep 17 00:00:00 2001 From: Dan Milne Date: Wed, 19 Feb 2025 19:05:13 +1100 Subject: [PATCH] Add logging. Use the normal PG ports. --- multidb-pg-pgbouncer/README.md | 6 ++++++ multidb-pg-pgbouncer/compose.yaml | 10 ++++++---- multidb-pg-pgbouncer/postgresql.cpx11.conf | 8 ++++++++ multidb-pg-pgbouncer/postgresql.nano.conf | 8 ++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/multidb-pg-pgbouncer/README.md b/multidb-pg-pgbouncer/README.md index dac96be..c581eb7 100644 --- a/multidb-pg-pgbouncer/README.md +++ b/multidb-pg-pgbouncer/README.md @@ -16,7 +16,13 @@ In the compose.yaml, you'll see `postgresql.${HOST_KIND}.conf`. This lets you ha * CPX11 is a Hetzner host - 2 vCPUS, 2GB RAM * Nano is a Linode host - 1 vCPU, 1GB RAM +### POSTGRES_PASSWORD +Used to set the `postgres` user's password + ## Data directory If you're using this for Cache, per SolidCache, you may be happy to use named bind mountings and let Docker manage storage. Alternatively, bind mount a local directory for PostgreSQL to use. + +## Logging +This configuration will log to a mounted volume, using PostgreSQL logging, and not to Stderr / Docker logging as per the default image. diff --git a/multidb-pg-pgbouncer/compose.yaml b/multidb-pg-pgbouncer/compose.yaml index 331f4e0..78fda09 100644 --- a/multidb-pg-pgbouncer/compose.yaml +++ b/multidb-pg-pgbouncer/compose.yaml @@ -6,11 +6,13 @@ services: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_MULTIPLE_DATABASES: solid_cache, solid_queue ports: - - "${HOST_IP}:5431:5432" + - "${HOST_IP}:5432:5432" volumes: - ./postgresql.${HOST_KIND}.conf:/etc/postgresql/postgresql.conf:ro - ./multiple-databases.sh:/docker-entrypoint-initdb.d/multiple-databases.sh - - postgres_solid_stuff_data:/var/lib/postgresql/data + - ./pglogs:/var/log/postgresql + + - pgdata:/var/lib/postgresql/data # - /var/pgdata/17:/var/lib/postgresql/data command: ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"] @@ -21,10 +23,10 @@ services: depends_on: - solid-pg ports: - - "${HOST_IP}:6431:5432" + - "${HOST_IP}:6432:5432" volumes: - ./pgbouncer.ini:/etc/pgbouncer/pgbouncer.ini:ro - ./userlist.txt:/etc/pgbouncer/userlist.txt volumes: - postgres_solid_stuff_data: \ No newline at end of file + pgdata: \ No newline at end of file diff --git a/multidb-pg-pgbouncer/postgresql.cpx11.conf b/multidb-pg-pgbouncer/postgresql.cpx11.conf index fe61214..92b86d1 100644 --- a/multidb-pg-pgbouncer/postgresql.cpx11.conf +++ b/multidb-pg-pgbouncer/postgresql.cpx11.conf @@ -819,6 +819,14 @@ max_connections = 200 # (change requires restart) # CUSTOMIZED OPTIONS #------------------------------------------------------------------------------ +## Logging +log_directory = '/var/log/postgresql' +logging_collector = on +log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' +log_truncate_on_rotation = on +log_rotation_age = 1d +log_rotation_size = 10MB + # Add settings for extensions here # OS Type: linux diff --git a/multidb-pg-pgbouncer/postgresql.nano.conf b/multidb-pg-pgbouncer/postgresql.nano.conf index fe61214..92b86d1 100644 --- a/multidb-pg-pgbouncer/postgresql.nano.conf +++ b/multidb-pg-pgbouncer/postgresql.nano.conf @@ -819,6 +819,14 @@ max_connections = 200 # (change requires restart) # CUSTOMIZED OPTIONS #------------------------------------------------------------------------------ +## Logging +log_directory = '/var/log/postgresql' +logging_collector = on +log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' +log_truncate_on_rotation = on +log_rotation_age = 1d +log_rotation_size = 10MB + # Add settings for extensions here # OS Type: linux