Files
kra-new/deploy/docker/wait-backend.sh
T

20 lines
758 B
Bash

#!/usr/bin/env bash
set -euo pipefail
# The HTTP listener starts after migrations. Large indexes have no meaningful
# fixed startup deadline; a stopped/restarted process is an actual failure.
started=$SECONDS
echo 'Waiting for backend startup and database migrations to finish...'
while true; do
state=$(docker inspect --format '{{.State.Running}} {{.RestartCount}}' sw2-backend) || exit 1
if [[ "$state" != 'true 0' ]]; then
echo "Backend exited or restarted during initialization ($state); check the migration logs." >&2
exit 1
fi
if curl -fsS --max-time 3 http://127.0.0.1:9602/health >/dev/null 2>&1; then
printf 'Backend ready after %s seconds.\n' "$((SECONDS - started))"
exit 0
fi
sleep 2
done