-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·70 lines (60 loc) · 1.81 KB
/
start.sh
File metadata and controls
executable file
·70 lines (60 loc) · 1.81 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
#!/bin/bash
# Agentic RAG System - Start Script
# Usage: ./start.sh
set -e
PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)"
export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH"
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
cleanup() {
echo ""
echo -e "${YELLOW}Shutting down...${NC}"
[ -n "$BACKEND_PID" ] && kill "$BACKEND_PID" 2>/dev/null
[ -n "$FRONTEND_PID" ] && kill "$FRONTEND_PID" 2>/dev/null
wait 2>/dev/null
echo -e "${GREEN}Done.${NC}"
exit 0
}
trap cleanup SIGINT SIGTERM
# 1. Check PostgreSQL
echo -e "${YELLOW}Checking PostgreSQL...${NC}"
if ! pg_isready -q 2>/dev/null; then
echo -e "${YELLOW}Starting PostgreSQL...${NC}"
brew services start postgresql@15
sleep 2
fi
echo -e "${GREEN}PostgreSQL is running${NC}"
# 2. Start Backend
echo -e "${YELLOW}Starting backend on port 8000...${NC}"
cd "$PROJECT_DIR/backend"
source venv/bin/activate
uvicorn main:app --host 0.0.0.0 --port 8000 &
BACKEND_PID=$!
# Wait for backend to be ready
for i in $(seq 1 15); do
if curl -s http://localhost:8000/api/health > /dev/null 2>&1; then
echo -e "${GREEN}Backend ready${NC}"
break
fi
[ "$i" -eq 15 ] && echo -e "${RED}Backend failed to start${NC}" && exit 1
sleep 1
done
# 3. Start Frontend
echo -e "${YELLOW}Starting frontend on port 5173...${NC}"
cd "$PROJECT_DIR/frontend"
npm run dev &
FRONTEND_PID=$!
sleep 3
echo ""
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN} Agentic RAG System is running${NC}"
echo -e "${GREEN} Frontend: http://localhost:5173${NC}"
echo -e "${GREEN} Backend: http://localhost:8000${NC}"
echo -e "${GREEN} API docs: http://localhost:8000/docs${NC}"
echo -e "${GREEN}========================================${NC}"
echo -e "${YELLOW}Press Ctrl+C to stop${NC}"
echo ""
wait