Skip to content

SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]

Web UI: Kill the Flask server on exit. (#479)

Kirk Wightf25f33d07ffb
diff --git a/start_web_ui.sh b/start_web_ui.sh
index 9857a58c..480a8051 100755
--- a/start_web_ui.sh
+++ b/start_web_ui.sh
@@ -4,9 +4,12 @@ set -euo pipefail
this_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
-function stop_react {
+function cleanup {
echo "Stopping react server"
npx --prefix "${this_dir}/sweagent/frontend" pm2 delete swe-agent
+ echo "Stopping Flask server"
+ kill "$flask_pid" 2>/dev/null
+ echo "Cleanup complete"
}
function print_log {
@@ -18,9 +21,11 @@ function print_log {
trap print_log ERR
python sweagent/api/server.py > web_api.log 2>&1 &
+flask_pid=$!
+
cd "${this_dir}/sweagent/frontend"
npm install
-trap stop_react exit
+trap cleanup EXIT
npx pm2 start --name swe-agent npm -- start
echo "* If you are running on your own machine, then a browser window "