integration.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. export TELEMETRY_ENABLED=false
  15. reflex run --loglevel debug --env "$env_mode" "$@" & pid=$!
  16. # Within the context of this bash, $pid_in_bash is what we need to pass to "kill" on exit
  17. # This is true on all platforms.
  18. pid_in_bash=$pid
  19. trap "kill -INT $pid_in_bash ||:" EXIT
  20. echo "Started server with PID $pid"
  21. # Assume we run from the root of the repo
  22. popd
  23. # In Windows, our Python script below needs to work with the WINPID
  24. if [ -f /proc/$pid/winpid ]; then
  25. pid=$(cat /proc/$pid/winpid)
  26. echo "Windows detected, passing winpid $pid to port waiter"
  27. fi
  28. python scripts/wait_for_listening_port.py $check_ports --timeout=600 --server-pid "$pid"