| Server IP : 217.154.3.148 / Your IP : 216.73.216.90 Web Server : Apache System : Linux blissful-wright.217-154-3-148.plesk.page 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : gracious-boyd_hfhh1h8vo9n ( 10000) PHP Version : 8.3.31 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/gracious-boyd.217-154-3-148.plesk.page/nextjs/ |
Upload File : |
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
TS="$(date +%Y%m%d-%H%M%S)"
echo "[deploy:$TS] Building Next.js app..."
# Build logs captured to a timestamped file and echoed to console
npm run build 2>&1 | tee -a "build-${TS}-deploy.log"
echo "[deploy:$TS] Restarting PM2 app 'nextjs'..."
if pm2 describe nextjs >/dev/null 2>&1; then
pm2 restart nextjs
else
pm2 start ecosystem.config.js
fi
# Give it a moment to boot
sleep 2
echo "[deploy:$TS] Recent PM2 logs (nextjs):"
# Prefer pm2 logs if available; fallback to tailing files
if pm2 logs nextjs --lines 80 --nostream >/dev/null 2>&1; then
pm2 logs nextjs --lines 80 --nostream || true
else
LOGDIR="$HOME/.pm2/logs"
[ -f "$LOGDIR/nextjs-out.log" ] && { echo "== nextjs-out.log (tail) =="; tail -n 80 "$LOGDIR/nextjs-out.log"; }
[ -f "$LOGDIR/nextjs-error.log" ] && { echo "== nextjs-error.log (tail) =="; tail -n 80 "$LOGDIR/nextjs-error.log"; }
fi
echo "[deploy:$TS] Done."