#!/bin/bash # Test script to verify setup echo "๐Ÿงช Testing YouMusic Setup" echo "=========================" echo "" # Kill any existing processes echo "1. Cleaning up existing processes..." lsof -ti:8000 | xargs kill -9 2>/dev/null || true lsof -ti:3000 | xargs kill -9 2>/dev/null || true pkill -f "uvicorn" 2>/dev/null || true pkill -f "vite" 2>/dev/null || true sleep 2 echo " โœ… Ports cleared" # Test backend echo "" echo "2. Testing backend..." cd backend if [ ! -d ".venv" ]; then echo " โŒ Virtual environment not found" exit 1 fi source .venv/bin/activate if ! python -c "import uvicorn, fastapi" 2>/dev/null; then echo " โŒ Dependencies not installed" exit 1 fi echo " โœ… Backend dependencies OK" # Test frontend echo "" echo "3. Testing frontend..." cd ../frontend if [ ! -d "node_modules" ]; then echo " โŒ Node modules not found" exit 1 fi echo " โœ… Frontend dependencies OK" # Start backend in background echo "" echo "4. Starting backend..." cd ../backend source .venv/bin/activate python main.py > ../logs/test-backend.log 2>&1 & BACKEND_PID=$! echo " Started with PID: $BACKEND_PID" sleep 3 # Check if backend is running if ! kill -0 $BACKEND_PID 2>/dev/null; then echo " โŒ Backend failed to start" cat ../logs/test-backend.log exit 1 fi # Test backend endpoint if curl -s http://localhost:8000/health | grep -q "healthy"; then echo " โœ… Backend is responding at http://localhost:8000" else echo " โŒ Backend not responding" kill $BACKEND_PID 2>/dev/null cat ../logs/test-backend.log exit 1 fi # Start frontend in background echo "" echo "5. Starting frontend..." cd ../frontend npm run dev -- --host > ../logs/test-frontend.log 2>&1 & FRONTEND_PID=$! echo " Started with PID: $FRONTEND_PID" sleep 5 # Check if frontend is running if ! kill -0 $FRONTEND_PID 2>/dev/null; then echo " โŒ Frontend failed to start" cat ../logs/test-frontend.log kill $BACKEND_PID 2>/dev/null exit 1 fi echo " โœ… Frontend started" # Clean up echo "" echo "6. Cleaning up test processes..." kill $BACKEND_PID $FRONTEND_PID 2>/dev/null sleep 2 lsof -ti:8000 | xargs kill -9 2>/dev/null || true lsof -ti:3000 | xargs kill -9 2>/dev/null || true echo " โœ… Processes stopped" echo "" echo "=========================" echo "โœ… All tests passed!" echo "=========================" echo "" echo "Your setup is working! You can now run:" echo " ./dev-stack.sh" echo "" echo "URLs:" echo " Frontend: http://localhost:3000" echo " Backend: http://localhost:8000" echo " API Docs: http://localhost:8000/docs" echo ""