-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_application.sh
More file actions
101 lines (83 loc) · 2.35 KB
/
start_application.sh
File metadata and controls
101 lines (83 loc) · 2.35 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
#!/bin/bash
# AI Interview Coach - Startup Script for Linux/Mac
# Run this from the Ai_powered_interview_coach directory
echo "🚀 Starting AI Interview Coach..."
echo "================================="
# Check if we're in the right directory
if [ ! -d "backend" ] || [ ! -d "frontend" ]; then
echo "❌ Error: Please run this script from the Ai_powered_interview_coach directory"
exit 1
fi
# Function to check if a port is in use
check_port() {
if lsof -Pi :$1 -sTCP:LISTEN -t >/dev/null ; then
echo "⚠️ Port $1 is already in use"
return 1
else
return 0
fi
}
# Check ports
echo "🔍 Checking ports..."
check_port 8000 || echo " Backend port 8000 is busy"
check_port 5173 || echo " Frontend port 5173 is busy"
# Start Backend
echo ""
echo "🐍 Starting Backend (FastAPI)..."
cd backend
if [ ! -d "venv" ]; then
echo " No virtual environment found. Creating one..."
python3 -m venv venv
fi
# Activate virtual environment
source venv/bin/activate
# Install dependencies if needed
if [ ! -f ".deps_installed" ]; then
echo " Installing Python dependencies..."
pip install -r requirements.txt
touch .deps_installed
fi
# Start backend in background
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 &
BACKEND_PID=$!
echo " Backend started with PID: $BACKEND_PID"
# Go back to root directory
cd ..
# Start Frontend
echo ""
echo "⚛️ Starting Frontend (React)..."
cd frontend
# Install dependencies if needed
if [ ! -d "node_modules" ]; then
echo " Installing Node.js dependencies..."
npm install
fi
# Start frontend in background
npm run dev &
FRONTEND_PID=$!
echo " Frontend started with PID: $FRONTEND_PID"
# Go back to root directory
cd ..
echo ""
echo "✅ Services Started Successfully!"
echo "================================="
echo "🌐 Frontend: http://localhost:5173"
echo "🔧 Backend: http://localhost:8000"
echo "📚 API Docs: http://localhost:8000/docs"
echo ""
echo "💡 Press Ctrl+C to stop all services"
echo ""
# Function to cleanup on exit
cleanup() {
echo ""
echo "🛑 Stopping services..."
kill $BACKEND_PID 2>/dev/null
kill $FRONTEND_PID 2>/dev/null
echo "✅ All services stopped"
exit 0
}
# Set trap to cleanup on script exit
trap cleanup SIGINT SIGTERM
# Wait for user to stop
echo "🔄 Services are running. Waiting..."
wait