Last active
October 22, 2021 15:32
-
-
Save ludenus/9f0e1701932ac884bdbc7d64bcb93169 to your computer and use it in GitHub Desktop.
bash waiters curl, netcat, wget, cassandra
This file contains hidden or 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
while [[ "200" != "$(curl -v -s -o /dev/null -w '%{http_code}' ${url})" ]]; do | |
sleep 10 | |
done | |
function wait_wget() { | |
local url=$1 | |
while true; do | |
if wget "${url}"; then | |
echo "${url} is avaliable" | |
break; | |
else | |
echo "waiting for ${url} to become available..." | |
sleep 10 | |
fi | |
done; | |
} | |
function wait_nc() { | |
local host=$1 | |
local port=$2 | |
while true; do | |
if nc -zvw 1 ${host} ${port}; then | |
echo "tcp ${host}:${port} is available" | |
break; | |
else | |
echo "waiting for tcp ${host}:${port} ..." | |
sleep 10 | |
fi | |
done; | |
} | |
function wait_cassandra(){ | |
local host=$1 | |
local port=$2 | |
while true; do | |
if cqlsh ${host} ${port} -e 'describe keyspaces;'; then | |
echo "tcp ${host}:${port} is available" | |
break; | |
else | |
echo "waiting for tcp ${host}:${port} ..." | |
sleep 10 | |
fi | |
done; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment