mirror of
https://github.com/wahyd4/you-music.git
synced 2026-08-09 05:06:44 +10:00
92 lines
2.5 KiB
Bash
Executable File
92 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# YouMusic Development Server with Foreman-like Process Management
|
|
# Uses overmind (better than foreman for local dev)
|
|
|
|
set -e
|
|
|
|
echo "🚀 YouMusic - Starting Development Stack"
|
|
echo "========================================="
|
|
echo ""
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
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}"
|
|
exit 1
|
|
fi
|
|
|
|
# Check for process managers (in order of preference)
|
|
if command -v overmind &> /dev/null; then
|
|
echo -e "${GREEN}✅ Using overmind (best option)${NC}"
|
|
echo ""
|
|
echo -e "${BLUE}Shortcuts:${NC}"
|
|
echo " Ctrl+C - Stop all"
|
|
echo " overmind c - Connect to services (in another terminal)"
|
|
echo " overmind r - Restart a service"
|
|
echo ""
|
|
echo "Starting services..."
|
|
exec overmind start -f Procfile.dev
|
|
elif command -v hivemind &> /dev/null; then
|
|
echo -e "${GREEN}✅ Using hivemind${NC}"
|
|
echo ""
|
|
echo "Starting services..."
|
|
exec hivemind Procfile.dev
|
|
elif command -v foreman &> /dev/null; then
|
|
echo -e "${GREEN}✅ Using foreman${NC}"
|
|
echo ""
|
|
echo "Starting services..."
|
|
exec foreman start -f Procfile.dev
|
|
elif command -v nf &> /dev/null; then
|
|
echo -e "${GREEN}✅ Using node-foreman${NC}"
|
|
echo ""
|
|
echo "Starting services..."
|
|
exec nf start -j Procfile.dev
|
|
else
|
|
echo -e "${YELLOW}⚠️ No process manager found. Running in foreground mode...${NC}"
|
|
echo ""
|
|
echo -e "${BLUE}Press Ctrl+C to stop all services${NC}"
|
|
echo ""
|
|
|
|
# Cleanup function
|
|
cleanup() {
|
|
echo ""
|
|
echo -e "${YELLOW}Stopping services...${NC}"
|
|
kill $BACKEND_PID $FRONTEND_PID 2>/dev/null
|
|
wait $BACKEND_PID $FRONTEND_PID 2>/dev/null
|
|
echo -e "${GREEN}✅ All services stopped${NC}"
|
|
exit 0
|
|
}
|
|
|
|
trap cleanup SIGINT SIGTERM
|
|
|
|
# Start backend in background
|
|
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] /' &
|
|
BACKEND_PID=$!
|
|
cd ..
|
|
|
|
# Start frontend in background
|
|
cd frontend
|
|
npm run dev 2>&1 | sed 's/^/[frontend] /' &
|
|
FRONTEND_PID=$!
|
|
cd ..
|
|
|
|
echo -e "${GREEN}✅ Services started${NC}"
|
|
echo ""
|
|
echo "Frontend: http://localhost:3000"
|
|
echo "Backend: http://localhost:8000"
|
|
echo "API Docs: http://localhost:8000/docs"
|
|
echo ""
|
|
|
|
# Wait for both processes
|
|
wait
|
|
fi
|