浏览代码

chore: fix is-available script with a timeout

Karol Sójko 2 年之前
父节点
当前提交
2c53306f5a
共有 1 个文件被更改,包括 11 次插入5 次删除
  1. 11 5
      docker/is-available.sh

+ 11 - 5
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."