-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-dev.sh
More file actions
executable file
·117 lines (95 loc) · 2.83 KB
/
start-dev.sh
File metadata and controls
executable file
·117 lines (95 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# Development startup script for AI Quiz Generator
echo "🚀 Starting AI Quiz Generator in development mode..."
# Check if we're in the right directory
if [ ! -f "start-dev.sh" ]; then
echo "❌ Please run this script from the project root directory"
exit 1
fi
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check if Python is available
if ! command_exists python3 && ! command_exists python; then
echo "❌ Python is not installed or not in PATH"
exit 1
fi
# Check if Node.js is available
if ! command_exists node; then
echo "❌ Node.js is not installed or not in PATH"
exit 1
fi
# Check if npm is available
if ! command_exists npm; then
echo "❌ npm is not installed or not in PATH"
exit 1
fi
echo "✅ Prerequisites check passed"
# Copy environment files if they don't exist
if [ ! -f "backend/.env" ]; then
echo "📝 Creating backend .env file from development template..."
cp backend/env.development backend/.env
echo "⚠️ Please edit backend/.env and add your GROQ_API_KEY"
fi
if [ ! -f "client/.env.local" ]; then
echo "📝 Creating frontend .env.local file from development template..."
cp client/env.development client/.env.local
fi
# Start backend in background
echo "🔧 Starting backend server..."
cd backend
# Check if virtual environment exists
if [ -d "venv" ]; then
echo "📦 Using existing virtual environment"
source venv/bin/activate
elif [ -d "venv_new" ]; then
echo "📦 Using existing virtual environment (venv_new)"
source venv_new/bin/activate
else
echo "📦 Creating new virtual environment..."
python3 -m venv venv
source venv/bin/activate
echo "📦 Installing backend dependencies..."
pip install -r requirements.txt
fi
# Start backend server
echo "🚀 Starting backend on http://localhost:8000"
python -m app.main &
BACKEND_PID=$!
cd ..
# Wait a moment for backend to start
echo "⏳ Waiting for backend to start..."
sleep 3
# Start frontend
echo "🎨 Starting frontend development server..."
cd client
# Install frontend dependencies if needed
if [ ! -d "node_modules" ]; then
echo "📦 Installing frontend dependencies..."
npm install
fi
echo "🚀 Starting frontend on http://localhost:3000"
npm run dev &
FRONTEND_PID=$!
cd ..
echo ""
echo "🎉 Development servers started!"
echo "📱 Frontend: http://localhost:3000"
echo "🔧 Backend: http://localhost:8000"
echo "📚 API Docs: http://localhost:8000/docs"
echo ""
echo "Press Ctrl+C to stop all servers"
# Function to cleanup on exit
cleanup() {
echo ""
echo "🛑 Stopping development servers..."
kill $BACKEND_PID 2>/dev/null
kill $FRONTEND_PID 2>/dev/null
echo "✅ Servers stopped"
exit 0
}
# Set trap to cleanup on script exit
trap cleanup SIGINT SIGTERM
# Wait for both processes
wait