diff --git a/start_server.sh b/start_server.sh index 9afcc392..9dafc21f 100755 --- a/start_server.sh +++ b/start_server.sh @@ -120,7 +120,23 @@ echo "🔐 Starting SSL proxies on $PROXY_HOSTNAME..." npx local-ssl-proxy --source $BACKEND_SSL_PORT --target $BACKEND_PORT --hostname $PROXY_HOSTNAME > /dev/null 2>&1 & npx local-ssl-proxy --source $FRONTEND_SSL_PORT --target $FRONTEND_PORT --hostname $PROXY_HOSTNAME > /dev/null 2>&1 & -# 7. Print Unified Access Banner +# 7. Signal handlers for clean shutdown +cleanup() { + echo "" + echo "🛑 Shutting down services..." + pkill -P $$ > /dev/null 2>&1 + kill $(jobs -p) 2>/dev/null || true + pkill -f "uvicorn" 2>/dev/null || true + pkill -f "next-server" 2>/dev/null || true + pkill -f "local-ssl-proxy" 2>/dev/null || true + echo "✅ Cleanup complete" + exit 0 +} + +# Trap Ctrl-C (SIGINT) and other termination signals +trap cleanup SIGINT SIGTERM EXIT + +# 8. Print Unified Access Banner # Colors GREEN='\033[0;32m' @@ -150,7 +166,7 @@ echo "" echo -e " ${YELLOW}${BOLD}NOTE:${NC} If you see a 'Not Private' warning," echo -e " Click 'Advanced' -> 'Proceed' to continue." echo -e "${GREEN}=======================================================${NC}" -echo "Keep this window open while working." +echo "Keep this window open while working. Press Ctrl-C to stop." echo -e "${GREEN}=======================================================${NC}" # Wait for background processes