nginx-proxy-manager/scripts/wait-healthy
2020-05-09 17:21:33 -07:00

33 lines
567 B
Bash
Executable file

#!/bin/bash
. $(dirname "$0")/log
if [ "$1" == "" ]; then
echo "Waits for a docker container to be healthy."
echo "Usage: $0 docker-container"
exit 1
fi
SERVICE=$1
LOOPCOUNT=0
HEALTHY=
LIMIT=${2:-90}
log "Waiting for healthy: ${YELLOW}${SERVICE}" "info"
until [ "${HEALTHY}" = "healthy" ]; do
echo -n "."
sleep 1
HEALTHY="$(docker inspect -f '{{.State.Health.Status}}' $SERVICE)"
((LOOPCOUNT++))
if [ "$LOOPCOUNT" == "$LIMIT" ]; then
echo ""
echo ""
log "Timed out waiting for healthy" "danger"
exit 1
fi
done
echo ""
log "Healthy!" "success"