Switch viewer PM2 template to next start and add deploy-viewer.sh.
DEV should build once then run production Next.js instead of long-lived next dev.
This commit is contained in:
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build viewer for production and restart PM2 process.
|
||||
# Usage: ./scripts/deploy-viewer.sh [--skip-install]
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
VIEWER="$ROOT/viewer-frontend"
|
||||
SKIP_INSTALL=0
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--skip-install) SKIP_INSTALL=1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
cd "$VIEWER"
|
||||
if [[ "$SKIP_INSTALL" -eq 0 ]]; then
|
||||
npm ci --prefer-offline
|
||||
fi
|
||||
npm run build
|
||||
|
||||
cd "$ROOT"
|
||||
if pm2 describe punimtag-viewer >/dev/null 2>&1; then
|
||||
pm2 restart punimtag-viewer --update-env
|
||||
else
|
||||
pm2 start ecosystem.config.js --only punimtag-viewer
|
||||
fi
|
||||
|
||||
echo "Viewer deployed (next start). Logs: pm2 logs punimtag-viewer --lines 30"
|
||||
Reference in New Issue
Block a user