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
This commit is contained in:
2026-04-22 09:33:43 +03:00
parent a2847092ac
commit 8d9e8998f8

View File

@@ -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