Ver Fonte

优化deploy.sh脚本,增加PM2应用启动前的存在性检查,确保应用重启或启动时使用正确的Node参数。

wui há 6 meses atrás
pai
commit
06ab728fe4
1 ficheiros alterados com 8 adições e 2 exclusões
  1. 8 2
      deploy.sh

+ 8 - 2
deploy.sh

@@ -95,8 +95,14 @@ fi
 cp .env.production dist/.env
 cp package.json dist/package.json
 
-# 启动 PM2
-pm2 start dist/app.js --name tweb-api
+# 检查 PM2 应用是否已存在并启动
+if pm2 list | grep -q "tweb-api"; then
+    echo "🔄 重启现有的 PM2 应用..."
+    pm2 restart tweb-api --node-args="--experimental-specifier-resolution=node"
+else
+    echo "🚀 启动新的 PM2 应用..."
+    pm2 start dist/app.js --name tweb-api --node-args="--experimental-specifier-resolution=node"
+fi
 pm2 save
 
 echo "✅ 部署完成!"