qwc-services / qwc-docker

Docker containers for qwc-services
MIT License
46 stars 36 forks source link

Failed to start: container qwc-docker-qwc-postgis-1 is unhealthy #77

Closed bogolszczecin closed 7 months ago

bogolszczecin commented 8 months ago

I have tried to change from basic settings of qwc-postgis service into my existing database which I store data of users (it is also used by other app) When I run the docker-compose up, I get below error:

qwc-postgis-1                  | 2024-02-01 14:19:04.767 UTC [1] LOG:  database system is ready to accept connections
qwc-postgis-1                  | 2024-02-01 14:19:19.577 UTC [1] LOG:  server process (PID 112) exited with exit code 2
qwc-postgis-1                  | 2024-02-01 14:19:19.577 UTC [1] LOG:  terminating any other active server processes
qwc-postgis-1                  | 2024-02-01 14:19:19.578 UTC [1] LOG:  all server processes terminated; reinitializing
qwc-postgis-1                  | 2024-02-01 14:19:19.587 UTC [113] LOG:  database system was interrupted; last known up at 2024-02-01 14:19:04 UTC
qwc-postgis-1                  | 2024-02-01 14:19:19.784 UTC [113] LOG:  database system was not properly shut down; automatic recovery in progress
qwc-postgis-1                  | 2024-02-01 14:19:19.788 UTC [113] LOG:  redo starts at 0/1921A30
qwc-postgis-1                  | 2024-02-01 14:19:19.788 UTC [113] LOG:  invalid record length at 0/1921A68: wanted 24, got 0
qwc-postgis-1                  | 2024-02-01 14:19:19.788 UTC [113] LOG:  redo done at 0/1921A30 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
qwc-postgis-1                  | 2024-02-01 14:19:19.792 UTC [114] LOG:  checkpoint starting: end-of-recovery immediate wait
qwc-postgis-1                  | 2024-02-01 14:19:19.809 UTC [114] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.005 s, sync=0.002 s, total=0.019 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB
qwc-postgis-1                  | 2024-02-01 14:19:19.814 UTC [1] LOG:  database system is ready to accept connections
Gracefully stopping... (press Ctrl+C again to force)
dependency failed to start: container qwc-docker-qwc-postgis-1 is unhealthy

I did run the SQL commands on my pgadmin of server and it ended up successfully:

CREATE ROLE qgis_server LOGIN PASSWORD 'pass1'; 
CREATE ROLE qwc_admin LOGIN PASSWORD 'pass2'; 
CREATE ROLE qwc_service LOGIN PASSWORD 'pass3'; 
CREATE ROLE qwc_service_write LOGIN PASSWORD 'pass4'; 

CREATE DATABASE qwc_services; 
COMMENT ON DATABASE qwc_services IS 'DB for qwc-services'; 

CREATE SCHEMA qwc_config AUTHORIZATION qwc_admin; 
COMMENT ON SCHEMA qwc_config IS 'ConfigDB for qwc-services'; 

CREATE EXTENSION postgis; 
GRANT SELECT ON TABLE geometry_columns TO PUBLIC; 
GRANT SELECT ON TABLE geography_columns TO PUBLIC; 
GRANT SELECT ON TABLE spatial_ref_sys TO PUBLIC;

My changes in pg_service.conf are as below:

[qwc_configdb]
host=(hostname here)
port=5432
dbname=qwc_services
user=qwc_admin
password=(password here)
sslmode=disable

[qwc_geodb]
host=(hostname here)
port=5432
dbname=qwc_services
user=qwc_service
password=(password here)
sslmode=disable

I think finally my docker-compose.yml part of server is: services:

  qwc-postgis:
    image: postgres:15 # 15 refers to the Postgres major version
    restart: always
    environment:
      POSTGRES_DB: [db]
      POSTGRES_USER: [user]
      POSTGRES_PASSWORD: [pass]
      HOST: [host]
      PORT: 5432
      LISTEN_ADDRESS: [adress]
      LISTEN_PORT: 5439
    volumes:
     - ./volumes/db:/var/lib/postgresql/docker
     - ./volumes/db:/volumes/db
    ports:
     - "127.0.0.1:5439:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -h db"]
      interval: 10s
      timeout: 5s
      retries: 5
tpo commented 7 months ago

If you have your data in your own database server (as I understand), then you don't need qwc-postgis and comment it out in docker-compose.yml. Furthermore you can comment out dependencies on qwc-postgis in docker-compose.yml.

Assuming this fixes your problem I close this ticket. Reopen in case.