diff --git a/docker-compose/Makefile b/docker-compose/Makefile index 1025691644ab0ee77729e6dd0cf7a19464bc2599..9e0949fa703ff2fb47bfdcb40d050e5645edd8dd 100644 --- a/docker-compose/Makefile +++ b/docker-compose/Makefile @@ -224,16 +224,20 @@ restart: ## restart a service (usage: make restart <servicename>) attach: ## attach a service to an existing Tango network $(DOCKER_COMPOSE_ARGS) docker-compose $(ATTACH_COMPOSE_FILE_ARGS) up --no-recreate -d $(SERVICE) +time := 0 await: ## Await every container with total max timeout of 300, do not reset timeout - time=0 for i in $(SERVICE); do \ current_service=$$($(DOCKER_COMPOSE_ARGS) docker-compose $(COMPOSE_FILE_ARGS) ps -q $${i}); \ if [ -z "$${current_service}" ]; then \ continue; \ + fi; \ + service_has_health=$$(docker inspect -f '{{.State.Health.Status}}' $${current_service}); \ + if [ -z "$${service_has_health}" ]; then \ + continue; \ fi; \ while [ "$$(docker inspect -f '{{.State.Health.Status}}' $${current_service})" != "healthy" ] ; do \ sleep 1; \ - time=$$(expr $${time} + 1); \ + time=$$(expr $$time + 1); \ if [ $${time} -gt $(TIMEOUT) ]; then \ echo "Timeout reached waiting for $${i} to become healthy"; \ exit 1; \