3 ms·
Can you suggest to me one way for an API service to wait for a database to accept connections to run the database migrations without the API depending on the li
by stavepan 2y ago
Can you suggest to me one way for an API service to wait for a database to accept connections to run the database migrations without the API depending on the liveness of the database to start up?
- ivan_gammel 2y agoStart the server and respond 503 every time when your database and other dependencies are not ready. Couldn’t be easier.
- stavepan 2y agoMany people have the following setup in docker-compose.yml file. version: '3' services: mysql: image: mysql:8.0 app: build: . command: is_ready --timeout 10 --addr mysql:3306 -- <run migrations command> For cases like this, returning 503 every time the database is not ready, is not very convenient.
- liampulles 2y agoI think the pragmatic answer is you should wait for your database to be live before starting up. One just wants to lean on the side of depending on a few critical services rather than all potentially-utlizied application services.