Skip to content

Instantly share code, notes, and snippets.

@ludenus
Last active October 22, 2021 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ludenus/9f0e1701932ac884bdbc7d64bcb93169 to your computer and use it in GitHub Desktop.
Save ludenus/9f0e1701932ac884bdbc7d64bcb93169 to your computer and use it in GitHub Desktop.
bash waiters curl, netcat, wget, cassandra
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