From 2c53306f5a34390838d9f5158bbd5d711b3f566a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Tue, 7 Feb 2023 07:09:38 +0100 Subject: [PATCH] chore: fix is-available script with a timeout --- docker/is-available.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docker/is-available.sh b/docker/is-available.sh index a4e4fe8af..01c0ee979 100755 --- a/docker/is-available.sh +++ b/docker/is-available.sh @@ -3,9 +3,15 @@ WAIT_FOR_URL="$1" shift -while ! (curl -s $WAIT_FOR_URL | grep "Welcome"); do - echo "$WAIT_FOR_URL is unavailable yet - waiting for it to start" - sleep 10 +attempt=0 +while [ $attempt -le 180 ]; do + attempt=$(( $attempt + 1 )) + echo "# Waiting for all services to be up (attempt: $attempt) ..." + ping_api_gateway_result=`curl -s $WAIT_FOR_URL | grep "Welcome"` + if [ "$?" -eq "0" ]; then + sleep 2 # for warmup + echo "# All services are up!" + break + fi + sleep 2 done - -echo "$WAIT_FOR_URL is up. Proceeding to startup."