浏览代码

feat: 修改部署配置

sunxiao 8 月之前
父节点
当前提交
e9f6686509
共有 2 个文件被更改,包括 162 次插入14 次删除
  1. 27 14
      deploy/index.js
  2. 135 0
      vite.config.js.timestamp-1721636793265-401b503a5b6c9.mjs

+ 27 - 14
deploy/index.js

@@ -25,25 +25,38 @@ const getConfig = () => {
   return result;
 }
 
+
 const execRemoteCommand = async () => {
   const config = getConfig();
   const conn = new ssh2.Client();
+
   conn.on("ready", function () {
-    console.log(chalk.blue("ssh2 链接成功 - 执行 pm2 restart bigModelAdmin"));
-    conn.exec("pm2 restart bigModelAdmin", function (err, stream) {
+    console.log(chalk.blue("ssh2 链接成功"));
+
+    const commands = [
+      'cd /data/node_web/modelAdmin',
+      'pwd',
+      'pm2 list',
+      'pm2 del bigModelAdmin',
+      'pm2 start'
+    ];
+
+    conn.exec(commands.join(";"), { pty: true }, function (err, stream) {
       if (err) throw err;
-      console.log(
-        chalk.blue(``) + chalk.green(`---执行成功---`),
-      );
-      console.log(
-        chalk.blue(`✅`) + chalk.green(`---部署完成---`),
-      );
-      conn.end();
+      stream
+        .on('close', function (code, signal) {
+          console.log('Command 执行成功');
+          conn.end(); // 结束SSH连接
+        })
+        .on('data', function (data) {
+          process.stdout.write(data);
+        });
+
+      stream.stdin.end();
     });
   }).connect({ ...config });
 }
 
-
 // 部署
 const connectShell = async () => {
   const sftp = new Client();
@@ -79,11 +92,11 @@ const connectShell = async () => {
       spinner.info('文件上传结束')
       spinner.stop();
 
-      if (filterStage === 'prod') {
-        execRemoteCommand()
-      }
+      // if (filterStage === 'prod') {
+      execRemoteCommand()
+      // }
 
-      printMsg({ color: 'green', text: '上传完成,部署成功' });
+      printMsg({ color: 'green', text: '上传完成,准备指令中' });
       sftp.end();
     })
     .catch((err) => {

文件差异内容过多而无法显示
+ 135 - 0
vite.config.js.timestamp-1721636793265-401b503a5b6c9.mjs


部分文件因为文件数量过多而无法显示