Skip to content

Instantly share code, notes, and snippets.

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 sethkontny/73092e9d4582ac7b43da to your computer and use it in GitHub Desktop.
Save sethkontny/73092e9d4582ac7b43da to your computer and use it in GitHub Desktop.
TCP test_retry connection bash code snipet
#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