-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathstart_platform.sh
More file actions
executable file
·112 lines (93 loc) · 3.16 KB
/
start_platform.sh
File metadata and controls
executable file
·112 lines (93 loc) · 3.16 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
#!/bin/bash
# RedCalibur AI - Complete Stack Startup Script
# Starts Backend API + Frontend Dev Server
cd /home/crimson/Praneesh/RedCalibur
echo "🚀 Starting RedCalibur AI Platform..."
echo ""
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to cleanup on exit
cleanup() {
echo ""
echo "🛑 Stopping servers..."
pkill -f "uvicorn api.agent_api" 2>/dev/null
pkill -f "vite" 2>/dev/null
if [ -n "$BACKEND_PID" ]; then
kill $BACKEND_PID 2>/dev/null
fi
if [ -n "$FRONTEND_PID" ]; then
kill $FRONTEND_PID 2>/dev/null
fi
exit 0
}
trap cleanup INT TERM
# Check for Gemini API key
if [ ! -f ".env" ] || ! grep -q "GEMINI_API_KEY" .env; then
echo -e "${YELLOW}Warning: GEMINI_API_KEY not found in .env${NC}"
echo "AI features may not work. Add your key to .env file"
echo ""
fi
# Start backend
echo "🔧 Starting Backend API (Port 8000)..."
pkill -f "uvicorn api.agent_api" 2>/dev/null
sleep 1
# Start backend in background with proper shell
(source redcalibur-env/bin/activate && uvicorn api.agent_api:app --host 0.0.0.0 --port 8000) > /tmp/redcalibur_backend.log 2>&1 &
BACKEND_PID=$!
sleep 4
# Check if backend started
if curl -s http://localhost:8000/ > /dev/null 2>&1; then
echo -e "${GREEN}✅ Backend running on http://localhost:8000 (PID: $BACKEND_PID)${NC}"
else
echo -e "${RED}❌ Backend failed to start. Check /tmp/redcalibur_backend.log${NC}"
tail -20 /tmp/redcalibur_backend.log
exit 1
fi
echo ""
# Start frontend
echo "🎨 Starting Frontend (Port 5173)..."
cd frontend
npm run dev > /tmp/redcalibur_frontend.log 2>&1 &
FRONTEND_PID=$!
sleep 5
# Check if frontend started
if lsof -i :5173 > /dev/null 2>&1; then
echo -e "${GREEN}✅ Frontend running on http://localhost:5173${NC}"
else
echo -e "${RED}❌ Frontend failed to start. Check /tmp/redcalibur_frontend.log${NC}"
pkill -f "uvicorn api.agent_api"
exit 1
fi
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "🎉 RedCalibur AI Platform is READY!"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "📱 Open your browser:"
echo " → http://localhost:5173/"
echo ""
echo "📚 Backend API docs:"
echo " → http://localhost:8000/docs"
echo ""
echo "📝 Logs:"
echo " → Backend: /tmp/redcalibur_backend.log"
echo " → Frontend: /tmp/redcalibur_frontend.log"
echo ""
echo "⌨️ Press Ctrl+C to stop all servers"
echo ""
# Keep script running and wait for both processes
echo "Monitoring servers... (Backend PID: $BACKEND_PID, Frontend PID: $FRONTEND_PID)"
while kill -0 $BACKEND_PID 2>/dev/null && kill -0 $FRONTEND_PID 2>/dev/null; do
sleep 2
done
# If we get here, one of the processes died
if ! kill -0 $BACKEND_PID 2>/dev/null; then
echo -e "${RED}❌ Backend process died! Check /tmp/redcalibur_backend.log${NC}"
fi
if ! kill -0 $FRONTEND_PID 2>/dev/null; then
echo -e "${RED}❌ Frontend process died! Check /tmp/redcalibur_frontend.log${NC}"
fi
cleanup