fix(cli): improve API service readiness check in install script (#7468)
* fix: improve API service readiness check in install script * fix(cli): correct python indentation in api health check * fix(cli): prevent false positive api ready message on timeout
This commit is contained in:
parent
ce08c9193c
commit
8228ecc087
1 changed files with 37 additions and 5 deletions
|
|
@ -365,17 +365,49 @@ function startServices() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local api_container_id=$(docker container ls -q -f "name=$SERVICE_FOLDER-api")
|
local api_container_id=$(docker container ls -q -f "name=$SERVICE_FOLDER-api")
|
||||||
|
|
||||||
|
# Verify container exists
|
||||||
|
if [ -z "$api_container_id" ]; then
|
||||||
|
echo " Error: API container not found. Please check if services are running."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
local idx2=0
|
local idx2=0
|
||||||
while ! docker exec $api_container_id python3 -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/')" > /dev/null 2>&1;
|
local api_ready=true # assume success, flip on timeout
|
||||||
do
|
local max_wait_time=300 # 5 minutes timeout
|
||||||
local message=">> Waiting for API Service to Start"
|
local start_time=$(date +%s)
|
||||||
|
|
||||||
|
echo " Waiting for API Service to be ready..."
|
||||||
|
while ! docker exec "$api_container_id" python3 -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/', timeout=3)" > /dev/null 2>&1; do
|
||||||
|
local current_time=$(date +%s)
|
||||||
|
local elapsed_time=$((current_time - start_time))
|
||||||
|
|
||||||
|
if [ $elapsed_time -gt $max_wait_time ]; then
|
||||||
|
echo ""
|
||||||
|
echo " API Service health check timed out after 5 minutes"
|
||||||
|
echo " Checking if API container is still running..."
|
||||||
|
if docker ps | grep -q "$SERVICE_FOLDER-api"; then
|
||||||
|
echo " API container is running but did not pass the health-check. Continuing without marking it ready."
|
||||||
|
api_ready=false
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo " API container is not running. Please check logs."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local message=">> Waiting for API Service to Start (${elapsed_time}s)"
|
||||||
local dots=$(printf '%*s' $idx2 | tr ' ' '.')
|
local dots=$(printf '%*s' $idx2 | tr ' ' '.')
|
||||||
echo -ne "\r$message$dots"
|
echo -ne "\r$message$dots"
|
||||||
((idx2++))
|
((idx2++))
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
printf "\r\033[K"
|
printf "\r\033[K"
|
||||||
echo " API Service started successfully ✅"
|
if [ "$api_ready" = true ]; then
|
||||||
|
echo " API Service started successfully ✅"
|
||||||
|
else
|
||||||
|
echo " ⚠️ API Service did not respond to health-check – please verify manually."
|
||||||
|
fi
|
||||||
source "${DOCKER_ENV_PATH}"
|
source "${DOCKER_ENV_PATH}"
|
||||||
echo " Plane Server started successfully ✅"
|
echo " Plane Server started successfully ✅"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue