integration.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. GNU nano 4.8 run_bash.sh #!/bin/bash
  2. cd "$1"
  3. curl -fsSL https://bun.sh/install | bash -s -- bun-v0.5.5
  4. set -e
  5. if [ "$2" = "dev" ]; then
  6. timeout 2m poetry run pc run --env "$2" || exit 0 & sleep 50
  7. else
  8. timeout 5m poetry run pc run --env "$2" || exit 0 & sleep 250
  9. fi
  10. # set the HOST to request
  11. HOST="127.0.0.1"
  12. FRONTEND_PORT="3000"
  13. API_PORT="8000"
  14. # make the curl request and save the response and HTTP status code
  15. RESPONSE=$(curl -s -w "\n%{http_code}" "$HOST:$FRONTEND_PORT")
  16. # extract the HTTP status code from the response
  17. HTTP_STATUS=$(echo "$RESPONSE" | tail -n1)
  18. # check for errors based on the HTTP status code
  19. if [[ $HTTP_STATUS -ge 400 ]]; then
  20. echo "Error: HTTP status code $HTTP_STATUS"
  21. exit 1
  22. fi
  23. # check for errors on API server
  24. API_RESPONSE=$(curl --silent "$HOST:$API_PORT/ping")
  25. if echo "$API_RESPONSE" | grep -q "pong"; then
  26. echo "success with HTTP STATUS: $HTTP_STATUS"
  27. exit 0
  28. else
  29. echo "Error starting API server"
  30. exit 1
  31. fi