mirror of
https://github.com/wahyd4/you-music.git
synced 2026-08-08 20:59:47 +10:00
112 lines
2.6 KiB
Bash
Executable File
112 lines
2.6 KiB
Bash
Executable File
#!/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 ""
|