integration.sh 1015 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. # Change directory to the first argument passed to the script
  3. project_dir=$1
  4. shift
  5. pushd "$project_dir" || exit 1
  6. echo "Changed directory to $project_dir"
  7. # So we get stdout / stderr from Python ASAP. Without this, delays can be very long (e.g. on Windows, Github Actions)
  8. export PYTHONUNBUFFERED=1
  9. env_mode=$1
  10. shift
  11. check_ports=${1:-3000 8000}
  12. shift
  13. # Start the server in the background
  14. reflex run --loglevel debug --env "$env_mode" "$@" & pid=$!
  15. # Within the context of this bash, $pid_in_bash is what we need to pass to "kill" on exit
  16. # This is true on all platforms.
  17. pid_in_bash=$pid
  18. trap "kill -INT $pid_in_bash ||:" EXIT
  19. echo "Started server with PID $pid"
  20. # Assume we run from the root of the repo
  21. popd
  22. # In Windows, our Python script below needs to work with the WINPID
  23. if [ -f /proc/$pid/winpid ]; then
  24. pid=$(cat /proc/$pid/winpid)
  25. echo "Windows detected, passing winpid $pid to port waiter"
  26. fi
  27. python scripts/wait_for_listening_port.py 3000 8000 --timeout=600 --server-pid "$pid"