From eec5c214e923c4f8d418a7213bd5ffc1043bdbb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=91=D0=BE=D0=B1?= =?UTF-8?q?=D1=8B=D1=80=D0=B5=D0=B2?= Date: Sun, 24 May 2026 22:55:53 +0300 Subject: [PATCH] fix(deploy): run next start from repo root on VPS Standalone traced node_modules were incomplete after partial sync; use npm start with production deps at INSTALL_DIR for reliable boots. Co-authored-by: Cursor --- install.sh | 9 ++++----- uninstall.sh | 10 +++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index f8b1130..0964c9e 100755 --- a/install.sh +++ b/install.sh @@ -109,11 +109,10 @@ build_app() { npx prisma generate npx prisma db push npm run build - rm -rf node_modules + # Keep production deps at repo root; `next start` is more reliable than + # standalone on small VPS (avoids incomplete traced node_modules). npm ci --omit=dev npx prisma generate - cp -r .next/static .next/standalone/.next/static - cp -r public .next/standalone/public journalctl --vacuum-size=80M 2>/dev/null || true apt-get clean 2>/dev/null || true } @@ -128,12 +127,12 @@ Wants=docker.service [Service] Type=simple -WorkingDirectory=${INSTALL_DIR}/.next/standalone +WorkingDirectory=${INSTALL_DIR} EnvironmentFile=${INSTALL_DIR}/.env Environment=HOSTNAME=0.0.0.0 Environment=PORT=${APP_PORT} Environment=NODE_ENV=production -ExecStart=/usr/bin/node server.js +ExecStart=/usr/bin/npm run start --silent Restart=on-failure RestartSec=5 diff --git a/uninstall.sh b/uninstall.sh index 4aecb88..984841c 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -2,7 +2,7 @@ # Domain Scanner — one-command uninstall set -euo pipefail -INSTALL_DIR="${DOMAIN_SCANNER_INSTALL_DIR:-/opt/domain_web}" +INSTALL_DIR="${DOMAIN_SCANNER_INSTALL_DIR:-/opt/domain-scanner}" SERVICE_NAME="domain-scanner" NGINX_SITE="domain-scanner" LEGACY_SERVICE="geoexport-site" @@ -27,6 +27,13 @@ stop_docker() { fi } +stop_app() { + systemctl stop "${SERVICE_NAME}.service" 2>/dev/null || true + systemctl disable "${SERVICE_NAME}.service" 2>/dev/null || true + rm -f "/etc/systemd/system/${SERVICE_NAME}.service" + systemctl daemon-reload +} + stop_legacy() { systemctl stop "${LEGACY_SERVICE}.service" 2>/dev/null || true systemctl disable "${LEGACY_SERVICE}.service" 2>/dev/null || true @@ -51,6 +58,7 @@ remove_files() { } need_root +stop_app stop_docker stop_legacy remove_nginx