From 60a41f87d57c137d44e57c78caa719011f1ed856 Mon Sep 17 00:00:00 2001
From: "Menezes, Luke J (PG/T - Comp Sci & Elec Eng)" <lm01906@surrey.ac.uk>
Date: Thu, 23 May 2024 18:04:18 +0000
Subject: [PATCH] Upload New File

---
 stop_flask.sh | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 stop_flask.sh

diff --git a/stop_flask.sh b/stop_flask.sh
new file mode 100644
index 0000000..2fabd5e
--- /dev/null
+++ b/stop_flask.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# Find the PID of the Flask application using lsof
+FLASK_PID=$(lsof -t -i :8080)
+
+if [ -z "$FLASK_PID" ]; then
+  echo "Flask application is not running on port 8080"
+else
+  # Terminate the Flask application
+  kill $FLASK_PID
+
+  # Wait for a moment to ensure the process has been terminated
+  sleep 2
+
+  # Check if the process is still running
+  if lsof -i :8080 > /dev/null; then
+    echo "Failed to terminate Flask application, forcing termination"
+    kill -9 $FLASK_PID
+  else
+    echo "Flask application terminated successfully"
+  fi
+fi
\ No newline at end of file
-- 
GitLab