start_web_ui.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. this_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
  4. function cleanup {
  5. echo "Stopping react server"
  6. npx --prefix "${this_dir}/sweagent/frontend" pm2 delete swe-agent
  7. echo "Stopping Flask server"
  8. kill "$flask_pid" 2>/dev/null
  9. echo "Cleanup complete"
  10. }
  11. function print_log {
  12. echo "Something went wrong. Here's web_api.log:"
  13. echo "----------"
  14. cat web_api.log
  15. echo "----------"
  16. }
  17. trap print_log ERR
  18. python sweagent/api/server.py > web_api.log 2>&1 &
  19. flask_pid=$!
  20. cd "${this_dir}/sweagent/frontend"
  21. npm install
  22. trap cleanup EXIT
  23. npx pm2 start --name swe-agent npm -- start
  24. echo "* If you are running on your own machine, then a browser window "
  25. echo " should have already opened. If not, wait a few more seconds, then "
  26. echo " open your browser at http://localhost:3000"
  27. echo "* If you are running in github codespaces, please click the popup "
  28. echo " that offers to forward port 3000 (not 8000!)."
  29. echo " Missed it? Find more information at "
  30. echo " https://princeton-nlp.github.io/SWE-agent/installation/codespaces#running-the-web-ui"
  31. echo "* Something went wrong? Please check "
  32. echo " web_api.log for error messages!"
  33. echo "* See here for more information: https://princeton-nlp.github.io/SWE-agent/usage/web_ui/"
  34. cd ../../
  35. wait
  36. exit $?