pandora/docker/wait-for
2019-07-06 18:12:32 +02:00

17 lines
262 B
Bash
Executable file

#!/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