Retry browser runtime verification
This commit is contained in:
@@ -4,6 +4,7 @@ set -euo pipefail
|
|||||||
FRONTEND_URL="${1:-http://localhost:1202}"
|
FRONTEND_URL="${1:-http://localhost:1202}"
|
||||||
BACKEND_HEALTH_URL="${2:-}"
|
BACKEND_HEALTH_URL="${2:-}"
|
||||||
API_URL="${FRONTEND_URL%/}/api/v1/projects"
|
API_URL="${FRONTEND_URL%/}/api/v1/projects"
|
||||||
|
ICON_URL="${FRONTEND_URL%/}/geointel-icon.svg"
|
||||||
|
|
||||||
if ! command -v curl >/dev/null 2>&1; then
|
if ! command -v curl >/dev/null 2>&1; then
|
||||||
echo "curl is required for browser runtime verification" >&2
|
echo "curl is required for browser runtime verification" >&2
|
||||||
@@ -13,14 +14,37 @@ fi
|
|||||||
echo "== GeoIntel browser runtime verification =="
|
echo "== GeoIntel browser runtime verification =="
|
||||||
echo "Frontend: ${FRONTEND_URL}"
|
echo "Frontend: ${FRONTEND_URL}"
|
||||||
echo "API through frontend proxy: ${API_URL}"
|
echo "API through frontend proxy: ${API_URL}"
|
||||||
|
echo "Icon: ${ICON_URL}"
|
||||||
|
|
||||||
|
frontend_status=""
|
||||||
|
api_response=""
|
||||||
|
icon_status=""
|
||||||
|
|
||||||
|
for attempt in $(seq 1 60); do
|
||||||
|
frontend_status="$(curl -fsS -o /dev/null -w "%{http_code}" "${FRONTEND_URL}" 2>/dev/null || true)"
|
||||||
|
icon_status="$(curl -fsS -o /dev/null -w "%{http_code}" "${ICON_URL}" 2>/dev/null || true)"
|
||||||
|
api_response="$(curl -fsS "${API_URL}" 2>/dev/null || true)"
|
||||||
|
|
||||||
|
if [ "${frontend_status}" = "200" ] \
|
||||||
|
&& [ "${icon_status}" = "200" ] \
|
||||||
|
&& printf '%s' "${api_response}" | grep -q '"data"'; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Browser runtime not ready yet (${attempt}/60): frontend=${frontend_status:-none} icon=${icon_status:-none}"
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
frontend_status="$(curl -fsS -o /dev/null -w "%{http_code}" "${FRONTEND_URL}")"
|
|
||||||
if [ "${frontend_status}" != "200" ]; then
|
if [ "${frontend_status}" != "200" ]; then
|
||||||
echo "Frontend returned HTTP ${frontend_status}, expected 200" >&2
|
echo "Frontend returned HTTP ${frontend_status:-none}, expected 200" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${icon_status}" != "200" ]; then
|
||||||
|
echo "Icon returned HTTP ${icon_status:-none}, expected 200" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
api_response="$(curl -fsS "${API_URL}")"
|
|
||||||
case "${api_response}" in
|
case "${api_response}" in
|
||||||
*"<!doctype html"*|*"<html"*)
|
*"<!doctype html"*|*"<html"*)
|
||||||
echo "Frontend API proxy returned HTML instead of the backend JSON envelope." >&2
|
echo "Frontend API proxy returned HTML instead of the backend JSON envelope." >&2
|
||||||
|
|||||||
Reference in New Issue
Block a user