-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·139 lines (119 loc) · 4.2 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·139 lines (119 loc) · 4.2 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
133
134
135
136
137
138
139
#!/bin/bash
# frfr - Document Fact Extraction
# Usage: ./run.sh [--no-frontend] [--build]
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Parse arguments
NO_FRONTEND=false
BUILD_FRONTEND=false
for arg in "$@"; do
case $arg in
--no-frontend)
NO_FRONTEND=true
;;
--build)
BUILD_FRONTEND=true
;;
esac
done
# Cleanup function
cleanup() {
echo -e "\n${YELLOW}Shutting down...${NC}"
if [ ! -z "$BACKEND_PID" ]; then
kill $BACKEND_PID 2>/dev/null || true
fi
if [ ! -z "$FRONTEND_PID" ]; then
kill $FRONTEND_PID 2>/dev/null || true
fi
exit 0
}
trap cleanup SIGINT SIGTERM
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE} frfr - Document Fact Extraction${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
# Check for required tools
echo -e "${YELLOW}Checking dependencies...${NC}"
if ! command -v go &> /dev/null; then
echo -e "${RED}Error: Go is not installed${NC}"
exit 1
fi
echo -e " ${GREEN}✓${NC} Go $(go version | awk '{print $3}')"
if ! command -v node &> /dev/null; then
echo -e "${RED}Error: Node.js is not installed${NC}"
exit 1
fi
echo -e " ${GREEN}✓${NC} Node.js $(node --version)"
# Check Claude API credentials
if [ -n "$ANTHROPIC_API_KEY" ]; then
echo -e " ${GREEN}✓${NC} Claude API: using explicit API key"
else
if command -v claude &> /dev/null; then
echo -e " ${GREEN}✓${NC} Claude API: using native credentials (claude CLI)"
else
echo -e " ${YELLOW}!${NC} Claude API: claude CLI not found, fact extraction may fail"
echo -e " Install with: ${BLUE}npm install -g @anthropic-ai/claude-code${NC}"
echo -e " Or set: ${BLUE}export ANTHROPIC_API_KEY=your_key${NC}"
fi
fi
# Install frontend dependencies if needed
if [ "$NO_FRONTEND" = false ]; then
cd "$SCRIPT_DIR/frontend"
if [ ! -d "node_modules" ]; then
echo -e "\n${YELLOW}Installing frontend dependencies...${NC}"
npm install --silent
fi
echo -e " ${GREEN}✓${NC} Frontend dependencies ready"
fi
# Build Go backend
echo -e "\n${YELLOW}Building Go backend...${NC}"
cd "$SCRIPT_DIR/backend"
go build -o frfr-server ./cmd/server
echo -e " ${GREEN}✓${NC} Backend built"
# Start backend
echo -e "\n${YELLOW}Starting backend server...${NC}"
./frfr-server &
BACKEND_PID=$!
sleep 1
# Check if backend started
if ! kill -0 $BACKEND_PID 2>/dev/null; then
echo -e "${RED}Error: Backend failed to start${NC}"
exit 1
fi
echo -e " ${GREEN}✓${NC} Backend running on http://localhost:8080"
# Start frontend
if [ "$NO_FRONTEND" = false ]; then
echo -e "\n${YELLOW}Starting frontend...${NC}"
cd "$SCRIPT_DIR/frontend"
if [ "$BUILD_FRONTEND" = true ]; then
echo -e " Building production frontend..."
npm run build --silent
echo -e " ${GREEN}✓${NC} Frontend built to dist/"
echo -e "\n${GREEN}Backend ready at http://localhost:8080${NC}"
echo -e "Serve frontend with: ${BLUE}npx serve frontend/dist${NC}"
else
npm run dev -- --host &>/dev/null &
FRONTEND_PID=$!
sleep 2
echo -e " ${GREEN}✓${NC} Frontend running on http://localhost:3000"
fi
fi
# Print status
echo -e "\n${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${GREEN} frfr is running!${NC}"
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo -e " ${BLUE}Frontend:${NC} http://localhost:3000"
echo -e " ${BLUE}API:${NC} http://localhost:8080/api"
echo ""
echo -e " Press ${YELLOW}Ctrl+C${NC} to stop"
echo ""
# Wait for processes
wait