-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstart-pm2.sh
More file actions
executable file
·70 lines (61 loc) · 2.01 KB
/
start-pm2.sh
File metadata and controls
executable file
·70 lines (61 loc) · 2.01 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
# PaperCode PM2 Startup Script
echo "========================================="
echo "Starting PaperCode with PM2"
echo "========================================="
# Check if PM2 is installed
if ! command -v pm2 &> /dev/null; then
echo "❌ PM2 is not installed. Installing PM2..."
npm install -g pm2
fi
# Create logs directory
mkdir -p logs
# Stop existing processes if any
echo "Stopping existing PM2 processes..."
pm2 stop ecosystem.config.js 2>/dev/null || true
pm2 delete ecosystem.config.js 2>/dev/null || true
# Update arXiv papers before starting
echo ""
echo "Updating arXiv papers..."
cd backend/scripts
python daily_arxiv_update.py --max-results 20 --days-back 1 > ../../logs/arxiv-startup.log 2>&1
if [ $? -eq 0 ]; then
echo "✅ ArXiv papers updated successfully"
else
echo "⚠️ ArXiv update failed (non-critical, continuing...)"
fi
cd ../..
# Start all services with PM2
echo ""
echo "Starting services with PM2..."
pm2 start ecosystem.config.js
# Save PM2 process list
pm2 save
# Display status
echo ""
echo "========================================="
echo "✅ PaperCode services started with PM2"
echo "========================================="
echo ""
echo "Useful PM2 commands:"
echo " pm2 status - View all services status"
echo " pm2 logs - View all logs"
echo " pm2 logs <name> - View specific service logs"
echo " pm2 restart all - Restart all services"
echo " pm2 stop all - Stop all services"
echo " pm2 monit - Monitor services in real-time"
echo ""
echo "Service URLs:"
echo " Frontend: http://localhost:3000"
echo " Backend: http://localhost:8003"
echo " API Docs: http://localhost:8003/docs"
echo ""
echo "ArXiv updater will run automatically at 2 AM daily"
echo ""
# Setup PM2 to start on system reboot (optional)
read -p "Do you want PM2 to start automatically on system reboot? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
pm2 startup
echo "✅ PM2 startup script generated. Follow the instructions above."
fi