CdC-SI / eak-copilot

The official repository of the EAK-Copilot project as part of the Innovation Fellowship 2024.
https://cdc-si.github.io/eak-copilot/
GNU General Public License v3.0
4 stars 0 forks source link

connection refused to db for auto-indexing #187

Closed K-Schubert closed 1 month ago

K-Schubert commented 1 month ago

Description

When running docker-compose up, auto-indexing (set in config.yaml) of sample FAQ/RAG data from indexing/app/main.py will get a "connection refused" error as DB service is not ready to accept incoming connections.

The docker-compose.yml configures the indexing service to wait for the db service to be launched, but there is still a "connection refused" error as this behaviour only waits for the launch of the db service and not for all it's initialization scripts to be finished executing.

Possible fix

I see 2 solutions:

  1. Setup a check_db_connection() method in utils/db.py (with wait time and max retries) which is awaited to return a positive health check before attempting to auto-index sample data in the db. This is functional but the logic is in python (not docker-compose).
  2. Setup a healthcheck within docker-compose.yml to initialize the indexing service only when the db service is truly initialized. This requires logic in an extra bash script.

@tabee what do you think is best? For the moment I've implemented option 1 which works (in utils/db.py and indexing/app/main.py).

tabee commented 1 month ago

@tabee what do you think is best? For the moment I've implemented option 1 which works (in utils/db.py and indexing/app/main.py).

@K-Schubert I guess a good soultion. I suggest to add an issue with low prio for add:

Setup a healthcheck within docker-compose.yml to initialize the indexing service only when the db service is truly initialized. This requires logic in an extra bash script.

later in the project. maybe we even mention that quickfix in the docuentation.