Created
January 21, 2019 14:29
-
-
Save smiklos/dcee8fc92b696b103ede4ed2a2a07d4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wait_for_local_port() { | |
local port=$1 | |
local timeout=$2 | |
local count=0 | |
local ret=1 | |
echo "waiting for S3:$port" | |
while [[ "$ret" -eq "1" && "$count" -lt "$timeout" ]] ; do | |
nc -z -w 1 localhost $port | |
ret=$? | |
if [ ! "$ret" -eq "0" ]; then | |
echo -n . | |
sleep 1 | |
count=$(($count+1)) | |
fi | |
done | |
echo "" | |
if [[ "$count" -eq "$timeout" ]]; then | |
echo "Server did not start in less than $timeout seconds. Exiting..." | |
exit 1 | |
fi | |
echo "Server got ready in ~${count} seconds. Starting test now..." | |
} | |
wait_for_local_port $1 $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment