diff --git a/bin/start_keycloak b/bin/start_keycloak index 335fa718..a95a9492 100755 --- a/bin/start_keycloak +++ b/bin/start_keycloak @@ -18,8 +18,6 @@ docker exec keycloak /opt/keycloak/bin/kc.sh import --file /tmp/finance-realm.js docker exec keycloak /opt/keycloak/bin/kc.sh import --file /tmp/spiffworkflow-realm.json || echo '' echo 'ran import finance realm' -docker logs -f keycloak - # to export: diff --git a/bin/wait_for_keycloak b/bin/wait_for_keycloak new file mode 100755 index 00000000..d7018465 --- /dev/null +++ b/bin/wait_for_keycloak @@ -0,0 +1,24 @@ +#!/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 +while [[ "$(curl -s -o /dev/null -w '%{http_code}' http://localhost:7002/realms/master/.well-known/openid-configuration)" != "200" ]]; do + 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