-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrebuild.sh
More file actions
executable file
·61 lines (50 loc) · 1.31 KB
/
rebuild.sh
File metadata and controls
executable file
·61 lines (50 loc) · 1.31 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
#!/bin/bash
set -e
cd "$(dirname "$0")"
APP_NAME="forgecrawl"
echo "========================================="
echo " ForgeCrawl Rebuild"
echo " $(date '+%Y-%m-%d %H:%M:%S')"
echo "========================================="
# Pull latest
echo ""
echo "Pulling latest changes..."
git pull origin main
# Install deps
echo ""
echo "Installing dependencies..."
pnpm install --frozen-lockfile
# Build the app package
echo ""
echo "Building @forgecrawl/app..."
pnpm --filter @forgecrawl/app build
# Verify build output exists
if [ ! -f "packages/app/.output/server/index.mjs" ]; then
echo "ERROR: Build output not found at packages/app/.output/server/index.mjs"
exit 1
fi
# Start or restart PM2
echo ""
if pm2 describe "$APP_NAME" > /dev/null 2>&1; then
echo "Restarting PM2 process..."
pm2 restart "$APP_NAME"
else
echo "Starting PM2 process for the first time..."
pm2 start ecosystem.config.cjs
pm2 save
fi
# Health check
echo ""
echo "Waiting for startup..."
sleep 3
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:5150/api/health 2>/dev/null || echo "000")
if [ "$HTTP_STATUS" = "200" ]; then
echo "Health check passed (HTTP $HTTP_STATUS)"
else
echo "WARNING: Health check returned HTTP $HTTP_STATUS"
echo "Check logs: pm2 logs $APP_NAME --lines 30"
fi
echo ""
pm2 status
echo ""
echo "Done."