-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·137 lines (120 loc) · 3.45 KB
/
start.sh
File metadata and controls
executable file
·137 lines (120 loc) · 3.45 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
#!/bin/bash
# Start script for PaperCode project (non-Docker version)
echo "========================================="
echo "Starting PaperCode Project"
echo "========================================="
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check prerequisites
echo "Checking prerequisites..."
if ! command_exists python3 && ! command_exists python; then
echo "❌ Python is not installed. Please install Python 3.8+"
exit 1
fi
if ! command_exists npm; then
echo "❌ npm is not installed. Please install Node.js and npm"
exit 1
fi
echo "✅ Prerequisites OK"
# Function to check if port is in use
check_port() {
if lsof -Pi :$1 -sTCP:LISTEN -t >/dev/null 2>&1; then
echo "⚠️ Port $1 is already in use"
read -p "Do you want to kill the process using port $1? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
lsof -ti:$1 | xargs kill -9 2>/dev/null
echo "✅ Killed process on port $1"
else
return 1
fi
fi
return 0
}
# Check if ports are available
echo ""
echo "Checking ports..."
check_port 8003 || { echo "Cannot start backend on port 8003"; exit 1; }
check_port 80 || { echo "Cannot start frontend on port 80"; exit 1; }
# Check if data exists
if [ ! -d "backend/api_data" ]; then
echo ""
echo "⚠️ API data not found. Running data processor..."
cd backend
if [ -f "create_full_db.py" ]; then
python create_full_db.py
else
echo "❌ Database creation script not found"
echo "Please run: cd backend/scripts && python complete_data_processor.py"
exit 1
fi
cd ..
fi
# Update arXiv papers
echo ""
echo "Updating arXiv papers..."
if [ -f "backend/scripts/daily_arxiv_update.py" ]; then
cd backend/scripts
python daily_arxiv_update.py --max-results 20 --days-back 1 > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "✅ ArXiv papers updated successfully"
else
echo "⚠️ ArXiv update failed (non-critical, continuing...)"
fi
cd ../..
else
echo "⚠️ ArXiv update script not found (skipping...)"
fi
# Start backend server
echo ""
echo "Starting backend server..."
cd backend
python full_api_server.py &
BACKEND_PID=$!
cd ..
echo "✅ Backend server started (PID: $BACKEND_PID)"
# Wait for backend to be ready
echo "Waiting for backend to initialize..."
sleep 3
# Check if backend is running
if ! curl -s http://localhost:8003 > /dev/null 2>&1; then
echo "❌ Backend failed to start"
kill $BACKEND_PID 2>/dev/null
exit 1
fi
# Start frontend server
echo ""
echo "Starting frontend server..."
cd frontend
npm start &
FRONTEND_PID=$!
cd ..
echo ""
echo "========================================="
echo "✅ PaperCode is starting up!"
echo "========================================="
echo ""
echo "Frontend: http://localhost (may take a moment to compile)"
echo "Backend: http://localhost:8003"
echo "API Docs: http://localhost:8003/docs"
echo ""
echo "Press Ctrl+C to stop all services"
echo ""
# Function to handle shutdown
shutdown() {
echo ""
echo "Shutting down services..."
kill $BACKEND_PID 2>/dev/null
kill $FRONTEND_PID 2>/dev/null
# Also kill any child processes
pkill -P $BACKEND_PID 2>/dev/null
pkill -P $FRONTEND_PID 2>/dev/null
echo "✅ Services stopped"
exit 0
}
# Set up trap for clean shutdown
trap shutdown INT TERM
# Wait for processes
wait $BACKEND_PID $FRONTEND_PID