pandora/docker/wait-for

18 lines
262 B
Text
Raw Normal View History

2019-07-06 16:12:32 +00:00
#!/bin/sh
TIMEOUT=15
HOST="$1"
PORT="$2"
for i in `seq $TIMEOUT` ; do
nc -z "$HOST" "$PORT" > /dev/null 2>&1
result=$?
if [ $result -eq 0 ] ; then
exit 0
fi
sleep 1
done
echo "Failed to connect to database at $HOST:$PORT" >&2
exit 1