spiffworkflow-backend/bin/wait_for_server_to_be_up

25 lines
666 B
Plaintext
Raw Normal View History

2022-06-17 14:35:23 +00:00
#!/usr/bin/env bash
function error_handler() {
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
exit "$2"
}
trap 'error_handler ${LINENO} $?' ERR
set -o errtrace -o errexit -o nounset -o pipefail
max_attempts="${1:-}"
if [[ -z "$max_attempts" ]]; then
max_attempts=100
fi
echo "waiting for backend to come up..."
attempts=0
2022-08-02 12:33:03 +00:00
while [[ "$(curl -s -o /dev/null -w '%{http_code}' http://localhost:7000/v1.0/status)" != "200" ]]; do
2022-06-17 14:35:23 +00:00
if [[ "$attempts" -gt "$max_attempts" ]]; then
>&2 echo "ERROR: Server not up after $max_attempts attempts. There is probably a problem"
exit 1
fi
attempts=$(( attempts + 1 ))
sleep 1
done