Skip to content

Instantly share code, notes, and snippets.

@chmouel
Last active December 11, 2015 09:16
Show Gist options
  • Save chmouel/c3b3d8f204ac43850411 to your computer and use it in GitHub Desktop.
Save chmouel/c3b3d8f204ac43850411 to your computer and use it in GitHub Desktop.
function check_up() {
service=$1
host=$2
port=$3
max=13 # 1 minute
counter=1
while true;do
python -c "import socket;s = socket.socket(socket.AF_INET, socket.SOCK_STREAM);s.connect(('$host', $port))" \
>/dev/null 2>/dev/null && break || \
echo "Waiting that $service on ${host}:${port} is started (sleeping for 5)"
if [[ ${counter} == ${max} ]];then
echo "Could not connect to ${service} after some time"
echo "Investigate locally the logs with fig logs"
exit 1
fi
sleep 5
(( counter++ ))
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment