#!/bin/bash echo Starting the authorization server, API gateway, resourece server, Vite dev server... # 1. Clean up background tasks on CTRL+C (SIGINT) or script exit cleanup() { echo " Catching CTRL+C. Terminating background jobs..." # Kill all child processes of this script pkill -P $$ exit 1 } # 2. Assign the cleanup function to the INT signal trap cleanup INT # 3. Start your background commands using '&' echo "Starting tasks..." cd 01-oauth2-server ./mvnw spring-boot:run & # Wait a few seconds until authorization server starts sleep 10 cd ../02-api-gateway ./mvnw spring-boot:run & cd ../03-resource-server ./mvnw spring-boot:run & sleep 10 cd ../04-react-app npm run dev # 4. Wait for all background processes to finish wait