sethkontny
8/4/2015 - 2:33 AM

TCP test_retry connection bash code snipet

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