28 lines
855 B
Bash
Executable File
28 lines
855 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
web_url=${WEB_BASE_URL:-http://localhost:8080}
|
|
search_url=${PUBLIC_SEARCH_URL:-$web_url/api/v1/public/search?query=}
|
|
|
|
check_url() {
|
|
url=$1
|
|
label=$2
|
|
if ! curl --fail --silent --show-error --max-time 10 "$url" >/dev/null; then
|
|
printf '%s\n' "${label} health check failed: ${url}" >&2
|
|
exit 1
|
|
fi
|
|
printf '%s\n' "${label} check passed"
|
|
}
|
|
|
|
if [ -n "${API_HEALTH_URL:-}" ]; then
|
|
check_url "$API_HEALTH_URL" 'API'
|
|
else
|
|
if ! docker compose -f compose.production.yaml exec -T api node -e "fetch('http://127.0.0.1:3000/health').then((response) => process.exit(response.ok ? 0 : 1)).catch(() => process.exit(1))"; then
|
|
printf '%s\n' 'API health check failed inside the Compose API service.' >&2
|
|
exit 1
|
|
fi
|
|
printf '%s\n' 'API check passed'
|
|
fi
|
|
check_url "$web_url/health" 'Web'
|
|
check_url "$search_url" 'Public search'
|