From 8d9e8998f8427395c931b3fb59cd5e47ebb019cb Mon Sep 17 00:00:00 2001 From: Daniel Bedeleanu Date: Wed, 22 Apr 2026 09:33:43 +0300 Subject: [PATCH] fix: clean shutdown handling in start_server.sh - Add signal traps for SIGINT (Ctrl-C) and SIGTERM - Cleanup function kills all child processes gracefully - Script now exits cleanly without hanging - Users can press Ctrl-C to stop all services at once --- start_server.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) 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