mirror of
https://github.com/wahyd4/you-music.git
synced 2026-08-09 05:06:44 +10:00
add db migration
This commit is contained in:
+139
-9
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# YouMusic Development Server with Foreman-like Process Management
|
||||
# Uses overmind (better than foreman for local dev)
|
||||
# YouMusic Development Stack - Complete Setup & Start
|
||||
# Handles: dependency checks, installation, migrations, and server startup
|
||||
|
||||
set -e
|
||||
|
||||
@@ -16,11 +16,141 @@ YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Check if setup was run
|
||||
if [ ! -d "backend/.venv" ] || [ ! -d "frontend/node_modules" ]; then
|
||||
echo -e "${RED}❌ Setup not complete. Run ./dev-setup.sh first${NC}"
|
||||
# ============================================================================
|
||||
# 1. Check System Dependencies
|
||||
# ============================================================================
|
||||
echo "🔍 Checking system dependencies..."
|
||||
|
||||
# Check Python 3.13
|
||||
if ! command -v python3.13 &> /dev/null; then
|
||||
echo -e "${RED}❌ Python 3.13 is required but not installed${NC}"
|
||||
echo "Install: brew install python@3.13 (macOS) or apt-get install python3.13 (Linux)"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "${GREEN}✅ Python 3.13 found${NC}"
|
||||
|
||||
# Check uv
|
||||
if ! command -v uv &> /dev/null; then
|
||||
echo -e "${YELLOW}⚠️ uv not found, installing...${NC}"
|
||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
if ! command -v uv &> /dev/null; then
|
||||
echo -e "${RED}❌ Failed to install uv${NC}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
echo -e "${GREEN}✅ uv found${NC}"
|
||||
|
||||
# Check Node.js
|
||||
if ! command -v node &> /dev/null; then
|
||||
echo -e "${RED}❌ Node.js is required but not installed${NC}"
|
||||
echo "Please install Node.js 18 or higher"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "${GREEN}✅ Node.js found${NC}"
|
||||
|
||||
# Check FFmpeg
|
||||
if ! command -v ffmpeg &> /dev/null; then
|
||||
echo -e "${YELLOW}⚠️ FFmpeg not found${NC}"
|
||||
echo "FFmpeg is required for audio processing"
|
||||
echo "Install: brew install ffmpeg (macOS) or apt-get install ffmpeg (Linux)"
|
||||
read -p "Continue anyway? (y/n) " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "${GREEN}✅ FFmpeg found${NC}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# ============================================================================
|
||||
# 2. Setup Project Directories
|
||||
# ============================================================================
|
||||
echo "📁 Setting up project directories..."
|
||||
mkdir -p data/music data/uploads data/temp logs
|
||||
echo -e "${GREEN}✅ Directories ready${NC}"
|
||||
echo ""
|
||||
|
||||
# ============================================================================
|
||||
# 3. Backend Setup
|
||||
# ============================================================================
|
||||
echo "🔧 Setting up Backend..."
|
||||
|
||||
# Create virtual environment if needed
|
||||
if [ ! -d "backend/.venv" ]; then
|
||||
echo "Creating Python 3.13 virtual environment..."
|
||||
cd backend
|
||||
uv venv --python 3.13
|
||||
cd ..
|
||||
fi
|
||||
|
||||
# Install/update Python dependencies
|
||||
echo "Installing Python dependencies..."
|
||||
cd backend
|
||||
source .venv/bin/activate
|
||||
uv pip install -r requirements.txt
|
||||
cd ..
|
||||
|
||||
# Create backend .env if needed
|
||||
if [ ! -f "backend/.env" ]; then
|
||||
echo "Creating backend .env file..."
|
||||
cp backend/.env.example backend/.env 2>/dev/null || echo "Warning: .env.example not found"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ Backend setup complete${NC}"
|
||||
echo ""
|
||||
|
||||
# ============================================================================
|
||||
# 4. Frontend Setup
|
||||
# ============================================================================
|
||||
echo "🎨 Setting up Frontend..."
|
||||
|
||||
# Install/update npm dependencies
|
||||
if [ ! -d "frontend/node_modules" ] || [ ! -f "frontend/node_modules/.bin/vite" ]; then
|
||||
echo "Installing npm dependencies..."
|
||||
cd frontend
|
||||
NODE_ENV= npm install --include=dev
|
||||
cd ..
|
||||
else
|
||||
echo "npm dependencies already installed"
|
||||
fi
|
||||
|
||||
# Create frontend .env if needed
|
||||
if [ ! -f "frontend/.env" ]; then
|
||||
echo "Creating frontend .env file..."
|
||||
cp frontend/.env.example frontend/.env 2>/dev/null || echo "Warning: .env.example not found"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ Frontend setup complete${NC}"
|
||||
echo ""
|
||||
|
||||
# ============================================================================
|
||||
# 5. Run Database Migrations
|
||||
# ============================================================================
|
||||
echo "🔄 Running database migrations..."
|
||||
cd backend
|
||||
source .venv/bin/activate
|
||||
|
||||
if [ -d "alembic" ]; then
|
||||
alembic upgrade head
|
||||
echo -e "${GREEN}✅ Database migrations complete${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ No alembic directory found, skipping migrations${NC}"
|
||||
fi
|
||||
|
||||
cd ..
|
||||
echo ""
|
||||
|
||||
# ============================================================================
|
||||
# 6. Start Development Servers
|
||||
# ============================================================================
|
||||
echo "🚀 Starting development servers..."
|
||||
echo ""
|
||||
|
||||
# Clean up overmind socket if it exists
|
||||
rm -f .overmind.sock
|
||||
|
||||
# Check for process managers (in order of preference)
|
||||
if command -v overmind &> /dev/null; then
|
||||
@@ -66,16 +196,16 @@ else
|
||||
|
||||
trap cleanup SIGINT SIGTERM
|
||||
|
||||
# Start backend in background
|
||||
# Start backend in background with output to console
|
||||
cd backend
|
||||
source .venv/bin/activate
|
||||
uv run uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 2>&1 | sed 's/^/[backend] /' &
|
||||
uv run uvicorn main:app --reload --host 0.0.0.0 --port 8000 2>&1 | sed 's/^/backend | /' &
|
||||
BACKEND_PID=$!
|
||||
cd ..
|
||||
|
||||
# Start frontend in background
|
||||
# Start frontend in background with output to console
|
||||
cd frontend
|
||||
npm run dev 2>&1 | sed 's/^/[frontend] /' &
|
||||
npm run dev 2>&1 | sed 's/^/frontend | /' &
|
||||
FRONTEND_PID=$!
|
||||
cd ..
|
||||
|
||||
|
||||
Reference in New Issue
Block a user