chore: fix is-available script with a timeout

This commit is contained in:
Karol Sójko
2023-02-07 07:09:38 +01:00
parent a3624357dc
commit 2c53306f5a

View File

@@ -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."