From 863ff4b968e8086cec991ec6aa6f1e1c7493ff77 Mon Sep 17 00:00:00 2001 From: Tim <47184194+imgde@users.noreply.github.com> Date: Fri, 13 Jun 2025 08:42:50 +0200 Subject: [PATCH] start.sh --- .gitignore | 1 + README.md | 4 ++-- start.sh | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100755 start.sh diff --git a/.gitignore b/.gitignore index e097a2e..a4fa160 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .vscode/ 00-backend/target/ 01-frontend/node_modules/ +*.log \ No newline at end of file diff --git a/README.md b/README.md index 038ea1c..6a3b1d5 100644 --- a/README.md +++ b/README.md @@ -33,10 +33,10 @@ Webshop-Projekt für htw saar Digitale Produktionssysteme ### 🥰 Unix Systems -- TODO: make script ```shell - + sh start.sh ``` + ### 🤮 Windows - TODO: make script diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..08615ef --- /dev/null +++ b/start.sh @@ -0,0 +1,29 @@ +#!/bin/sh + + +# Function to clean up background processes on script exit +cleanup() { + echo "[DPS] Cleaning up..." + pkill $backend_pid # pkill because subshells + pkill $frontend_pid + echo "[DPS] Cleaned up..." + exit +} + +# Trap SIGINT (Ctrl+C) +trap cleanup SIGINT +echo "[DPS] trapped" + +cd ./00-backend +( java -jar target/webshop-0.0.1-SNAPSHOT.jar 2>&1 | tee ../backend_latest.log ) & +backend_pid=$! +echo "[DPS] Backend started with PID $backend_pid" + +cd ../01-frontend +( npm start 2>&1 | tee ../frontend_latest.log ) & +frontend_pid=$! +echo "[DPS] Frontend started with PID $frontend_pid" + +echo "[DPS] Ctrl+C to stop" +# Wait indefinitely; cleanup will handle interruption +wait