-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart-fullstack.sh
More file actions
executable file
·132 lines (115 loc) · 3.35 KB
/
start-fullstack.sh
File metadata and controls
executable file
·132 lines (115 loc) · 3.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
# suRxit Full-Stack Startup Script
echo "🏥 suRxit - Full-Stack Medical AI Dashboard"
echo "============================================"
# Function to check if port is in use
check_port() {
if lsof -Pi :$1 -sTCP:LISTEN -t >/dev/null ; then
return 0 # Port is in use
else
return 1 # Port is free
fi
}
# Function to start backend
start_backend() {
echo "🚀 Starting Backend API..."
cd /workspaces/suRxit/backend
if [ ! -d "venv" ]; then
echo "📦 Creating virtual environment..."
python3 -m venv venv
fi
source venv/bin/activate
if [ ! -f "venv/.deps_installed" ]; then
echo "📥 Installing dependencies..."
pip install -r requirements.txt
touch venv/.deps_installed
fi
# Check if backend is already running
if check_port 8000; then
echo "✅ Backend already running on port 8000"
else
echo "📍 Starting backend on http://localhost:8000"
uvicorn simple_main:app --host 0.0.0.0 --port 8000 &
BACKEND_PID=$!
sleep 3 # Give backend time to start
if check_port 8000; then
echo "✅ Backend started successfully"
else
echo "❌ Backend failed to start"
return 1
fi
fi
}
# Function to start frontend
start_frontend() {
echo "🚀 Starting Frontend..."
cd /workspaces/suRxit/frontend
# Set to use real backend
sed -i 's/VITE_ENABLE_MOCK_DATA=true/VITE_ENABLE_MOCK_DATA=false/' .env
# Check if frontend is already running
if check_port 5173; then
echo "✅ Frontend already running on port 5173"
else
echo "📍 Starting frontend on http://localhost:5173"
npm run dev &
FRONTEND_PID=$!
sleep 5 # Give frontend time to start
if check_port 5173; then
echo "✅ Frontend started successfully"
else
echo "❌ Frontend failed to start"
return 1
fi
fi
}
# Function to show status
show_status() {
echo ""
echo "🌐 suRxit Dashboard Status:"
echo "=========================="
if check_port 8000; then
echo "✅ Backend API: http://localhost:8000"
echo "📖 API Docs: http://localhost:8000/docs"
else
echo "❌ Backend API: Not running"
fi
if check_port 5173; then
echo "✅ Frontend App: http://localhost:5173"
else
echo "❌ Frontend App: Not running"
fi
echo ""
echo "🔑 Test Credentials:"
echo " Email: doctor@example.com"
echo " Password: password"
echo ""
echo "💡 Tips:"
echo " - Use Ctrl+C to stop services"
echo " - Check logs in terminal for debugging"
echo " - Refresh browser if connection issues occur"
}
# Main execution
case "${1:-start}" in
"backend")
start_backend
;;
"frontend")
start_frontend
;;
"status")
show_status
;;
"stop")
echo "🛑 Stopping services..."
pkill -f "uvicorn.*simple_main:app" 2>/dev/null || true
pkill -f "vite.*dev" 2>/dev/null || true
echo "✅ Services stopped"
;;
"start"|*)
start_backend
if [ $? -eq 0 ]; then
start_frontend
fi
show_status
;;
esac