Skip to content

Instantly share code, notes, and snippets.

@rafaeltuelho
Last active August 29, 2015 14:26
Show Gist options
  • Save rafaeltuelho/aff24eefe8c6e48a6b49 to your computer and use it in GitHub Desktop.
Save rafaeltuelho/aff24eefe8c6e48a6b49 to your computer and use it in GitHub Desktop.
TCP test_retry connection bash code snippet
#test if the service is up
CONN_STATUS="DOWN"
COUNTER=0
while [ "$CONN_STATUS" == "DOWN" -a $COUNTER -lt 4 ]
do
CONN_STATUS=`(echo > /dev/tcp/$SERVICE_ADDR/$SERVICE_PORT) >/dev/null 2>&1 && echo "UP" || echo "DOWN"`
echo -e "\t SERVICE connection status: $CONN_STATUS"
echo -e "\t waintig 5s for Service connetion..."
sleep 5
let COUNTER=COUNTER+1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment