Don't send health api request multiple time if fails
This commit is contained in:
@@ -122,45 +122,34 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MAX_RETRIES=5 # Total attempts (1 initial + 4 retries)
|
||||
RETRY_INTERVAL=10 # Retry every 10 seconds after first failure
|
||||
echo "Waiting 1 minute before sending the health API request..."
|
||||
sleep 60
|
||||
|
||||
echo "Waiting 1 minute before the first health check..."
|
||||
sleep 60 # Initial wait before first attempt
|
||||
echo "Checking health API..."
|
||||
HEALTH_RESPONSE=$(curl -s 'http://localhost:3001/api/v1/health?force=true' \
|
||||
-H "Authorization: Bearer $API_KEY")
|
||||
|
||||
for ((i=1; i<=$MAX_RETRIES; i++)); do
|
||||
echo "Attempt $i/$MAX_RETRIES: Checking health API..."
|
||||
|
||||
HEALTH_RESPONSE=$(curl -s 'http://localhost:3001/api/v1/health?force=true' \
|
||||
-H "Authorization: Bearer $API_KEY")
|
||||
echo "Health API Response: $HEALTH_RESPONSE"
|
||||
|
||||
echo "Health API Response: $HEALTH_RESPONSE"
|
||||
WORKFLOWS_CREATE=$(echo "$HEALTH_RESPONSE" | jq -r '.workflows.create')
|
||||
WORKFLOWS_RUN=$(echo "$HEALTH_RESPONSE" | jq -r '.workflows.run')
|
||||
WORKFLOWS_RUN_FINISHED=$(echo "$HEALTH_RESPONSE" | jq -r '.workflows.run_finished')
|
||||
WORKFLOWS_RUN_STATUS=$(echo "$HEALTH_RESPONSE" | jq -r '.workflows.run_status')
|
||||
WORKFLOWS_DELETE=$(echo "$HEALTH_RESPONSE" | jq -r '.workflows.delete')
|
||||
|
||||
WORKFLOWS_CREATE=$(echo "$HEALTH_RESPONSE" | jq -r '.workflows.create')
|
||||
WORKFLOWS_RUN=$(echo "$HEALTH_RESPONSE" | jq -r '.workflows.run')
|
||||
WORKFLOWS_RUN_FINISHED=$(echo "$HEALTH_RESPONSE" | jq -r '.workflows.run_finished')
|
||||
WORKFLOWS_RUN_STATUS=$(echo "$HEALTH_RESPONSE" | jq -r '.workflows.run_status')
|
||||
WORKFLOWS_DELETE=$(echo "$HEALTH_RESPONSE" | jq -r '.workflows.delete')
|
||||
echo "WORKFLOWS_CREATE: $WORKFLOWS_CREATE"
|
||||
echo "WORKFLOWS_RUN: $WORKFLOWS_RUN"
|
||||
echo "WORKFLOWS_RUN_FINISHED: $WORKFLOWS_RUN_FINISHED"
|
||||
echo "WORKFLOWS_RUN_STATUS: $WORKFLOWS_RUN_STATUS"
|
||||
echo "WORKFLOWS_DELETE: $WORKFLOWS_DELETE"
|
||||
|
||||
echo "WORKFLOWS_CREATE: $WORKFLOWS_CREATE"
|
||||
echo "WORKFLOWS_RUN: $WORKFLOWS_RUN"
|
||||
echo "WORKFLOWS_RUN_FINISHED: $WORKFLOWS_RUN_FINISHED"
|
||||
echo "WORKFLOWS_RUN_STATUS: $WORKFLOWS_RUN_STATUS"
|
||||
echo "WORKFLOWS_DELETE: $WORKFLOWS_DELETE"
|
||||
|
||||
if [ "$WORKFLOWS_CREATE" = "true" ] && [ "$WORKFLOWS_RUN" = "true" ] && [ "$WORKFLOWS_RUN_FINISHED" = "true" ] && [ "$WORKFLOWS_RUN_STATUS" = "FINISHED" ] && [ "$WORKFLOWS_DELETE" = "true" ]; then
|
||||
echo "Health endpoint check was successful."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$i" -lt "$MAX_RETRIES" ]; then
|
||||
echo "Health check failed. Retrying in $RETRY_INTERVAL seconds..."
|
||||
sleep $RETRY_INTERVAL
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Health check failed after $MAX_RETRIES attempts."
|
||||
exit 1
|
||||
if [ "$WORKFLOWS_CREATE" = "true" ] && [ "$WORKFLOWS_RUN" = "true" ] && [ "$WORKFLOWS_RUN_FINISHED" = "true" ] && [ "$WORKFLOWS_RUN_STATUS" = "FINISHED" ] && [ "$WORKFLOWS_DELETE" = "true" ]; then
|
||||
echo "Health endpoint check was successful."
|
||||
exit 0
|
||||
else
|
||||
echo "Health check failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
notify:
|
||||
needs: build
|
||||
|
||||
Reference in New Issue
Block a user