is-available.sh 572 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. WAIT_FOR_URL="$1"
  3. shift
  4. LOGS_PATH="$1"
  5. shift
  6. attempt=0
  7. while [ $attempt -le 120 ]; do
  8. attempt=$(( $attempt + 1 ))
  9. echo "# Waiting for all services to be up (attempt: $attempt) ..."
  10. ping_api_gateway_result=`curl -s $WAIT_FOR_URL | grep "Welcome"`
  11. if [ "$?" -eq "0" ]; then
  12. sleep 2 # for warmup
  13. echo "# All services are up!"
  14. exit 0
  15. break
  16. fi
  17. sleep 2
  18. done
  19. echo "# Failed to wait for all services to be up!"
  20. echo "# Errors:"
  21. tail -n 50 $LOGS_PATH/*.err
  22. echo "# Logs:"
  23. tail -n 50 $LOGS_PATH/*.log
  24. exit 1