mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-01-30 18:36:29 +00:00
46 lines
1.4 KiB
Bash
Executable file
46 lines
1.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -Eeo pipefail
|
|
|
|
# This script waits 60 seconds by default for the backend and web-frontend services
|
|
# to become healthy.
|
|
|
|
# Keep in sync with src/baserow/config/settings/base.py:594
|
|
DEFAULT_APPLICATION_TEMPLATE="project-tracker"
|
|
|
|
baserow_ready() {
|
|
curlf() {
|
|
HTTP_CODE=$(curl --silent -o /dev/null --write-out "%{http_code}" --max-time 10 "$@")
|
|
if [[ ${HTTP_CODE} -lt 200 || ${HTTP_CODE} -gt 299 ]] ; then
|
|
echo "$1 not ready..."
|
|
return 22
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
templates_ready(){
|
|
TEMPLATES_JSON=$(curl --silent --max-time 10 "${PUBLIC_BACKEND_URL:-http://backend:8000}/api/templates/")
|
|
if [[ ${TEMPLATES_JSON} == *"$DEFAULT_APPLICATION_TEMPLATE"* ]] ; then
|
|
return 0
|
|
fi
|
|
echo "Template $DEFAULT_APPLICATION_TEMPLATE is missing..."
|
|
return 22
|
|
}
|
|
|
|
if curlf "${PUBLIC_WEB_FRONTEND_URL:-http://web-frontend:3000}/_health/" && curlf "${PUBLIC_BACKEND_URL:-http://backend:8000}/api/_health/" && templates_ready; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
for _ in $(seq 1 "${BASEROW_E2E_STARTUP_MAX_WAIT_TIME_SECONDS:-60}")
|
|
do
|
|
echo 'Waiting for backend, web-frontend and synced templates to be ready'
|
|
if baserow_ready; then
|
|
echo 'Baserow is ready! Exiting with success code.'
|
|
exit 0
|
|
fi
|
|
sleep 1
|
|
done
|
|
echo 'E2E services failed to startup in time, crashing the test.'
|
|
exit 1
|