-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-dev.sh
More file actions
114 lines (92 loc) · 2.79 KB
/
Copy pathstart-dev.sh
File metadata and controls
114 lines (92 loc) · 2.79 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
#!/bin/bash
# WebTrace AI Development Startup Script (Bash)
# This script starts both the backend and frontend development servers
echo "🚀 Starting WebTrace AI Development Environment..."
# Check if Python is installed
if command -v python3 &> /dev/null; then
python_version=$(python3 --version 2>&1)
echo "✅ Python found: $python_version"
else
echo "❌ Python not found. Please install Python 3.11+ and try again."
exit 1
fi
# Check if Node.js is installed
if command -v node &> /dev/null; then
node_version=$(node --version 2>&1)
echo "✅ Node.js found: $node_version"
else
echo "❌ Node.js not found. Please install Node.js 18+ and try again."
exit 1
fi
# Function to start backend
start_backend() {
echo "🔧 Starting Backend Server..."
# Change to backend directory
cd backend
# Check if virtual environment exists
if [ ! -d "venv" ]; then
echo "📦 Creating virtual environment..."
python3 -m venv venv
fi
# Activate virtual environment
echo "🔌 Activating virtual environment..."
source venv/bin/activate
# Install dependencies if requirements.txt is newer than venv
if [ requirements.txt -nt venv ]; then
echo "📥 Installing Python dependencies..."
pip install -r requirements.txt
fi
# Start the backend server
echo "🚀 Starting FastAPI server on http://localhost:8000"
uvicorn main:app --reload --host 0.0.0.0 --port 8000 &
BACKEND_PID=$!
# Return to root directory
cd ..
}
# Function to start frontend
start_frontend() {
echo "🎨 Starting Frontend Server..."
# Change to frontend directory
cd frontend
# Check if node_modules exists
if [ ! -d "node_modules" ]; then
echo "📥 Installing Node.js dependencies..."
npm install
fi
# Start the frontend server
echo "🚀 Starting Vite development server on http://localhost:5173"
npm run dev &
FRONTEND_PID=$!
# Return to root directory
cd ..
}
# Function to cleanup on exit
cleanup() {
echo ""
echo "🛑 Stopping servers..."
if [ ! -z "$BACKEND_PID" ]; then
kill $BACKEND_PID 2>/dev/null
fi
if [ ! -z "$FRONTEND_PID" ]; then
kill $FRONTEND_PID 2>/dev/null
fi
echo "✅ Servers stopped"
exit 0
}
# Set up signal handlers
trap cleanup SIGINT SIGTERM
# Start both servers
start_backend
sleep 3 # Give backend time to start
start_frontend
sleep 3 # Give frontend time to start
echo ""
echo "🎉 WebTrace AI Development Environment Started!"
echo ""
echo "📱 Frontend: http://localhost:5173"
echo "🔧 Backend API: http://localhost:8000"
echo "📚 API Documentation: http://localhost:8000/docs"
echo ""
echo "Press Ctrl+C to stop all servers"
# Keep the script running
wait