Browse Source

修复bug,

hl 1 year ago
parent
commit
680b8dde3d
1 changed files with 2 additions and 118 deletions
  1. 2 118
      src/robot.js

+ 2 - 118
src/robot.js

@@ -311,131 +311,15 @@ async function restartApp(param) {
 
 
     const closeResult = await closeApp(param)
-    logger.info('?', JSON.stringify(closeResult))
+    // logger.info('?', JSON.stringify(closeResult))
     while (true) {
         await delay(1000)
         const runResult = await run(param)
-        logger.info('??', JSON.stringify(runResult))
+        // logger.info('??', JSON.stringify(runResult))
         if (runResult) break
     }
 
 
-    // var isOK = false
-    // var killCount = 0;
-    // if (app.id === -1 || (app.childProcess === undefined && app.status === 0)) {
-    //     isOK = true;
-    // } else {
-    //     var pid = app.childProcess.pid
-    //     logger.info(`当前pid:${pid}`);
-    //     //1 通过指令查询是否存在
-    //     var pidIsOK = false
-    //     exec(`sudo ps -p ${pid} > /dev/null && echo "true" || echo "false"`, (error, stdout, stderr) => {
-    //         if (error) {
-    //             logger.error(`进程${pid} 查询失败: ${error}`);
-    //             return
-    //         }
-    //         logger.info(`进程查询结果:${stdout}`);
-    //         var z = `${stdout}`
-    //         if (z === "true") {
-    //             pidIsOK = true
-    //         }
-    //     });
-    //
-    //     if (pidIsOK) {
-    //         if (killCount === 0) {
-    //             killCount = 1
-    //             exec(`sudo kill ${pid}`, (error, stdout, stderr) => {
-    //                 if (error) {
-    //                     logger.error(`进程${pid} 杀死失败: ${error}`);
-    //                 }
-    //                 logger.info(`进程${pid} 杀死成功`);
-    //                 logger.info(`当前app:`, app);
-    //                 app.threadStatus = RobotStatus.STOP_PENDING
-    //                 robotStatus(app)
-    //                 isOK = true
-    //             });
-    //         } else {
-    //             logger.info(`灭杀指令已发送..等待结果!`);
-    //         }
-    //     }else{
-    //         isOK = true
-    //     }
-    // }
-    //
-    // while (true) {
-    //     await delay(2000);
-    //     if(isOK){
-    //         break
-    //     }else{
-    //         logger.info("----等待~~~")
-    //     }
-    // }
-
-    // //开始重启
-    // var killCount = 0;
-    // var waitForCondition = function (intervalDuration, conditionFunction) {
-    //     return new Promise((resolve, reject) => {
-    //         const intervalId = setInterval(() => {
-    //             if (conditionFunction()) {
-    //                 clearInterval(intervalId);
-    //                 resolve();
-    //             }
-    //         }, intervalDuration);
-    //     });
-    // }
-    //
-    //
-    // // 当这个条件变为true时,会结束等待
-    // await waitForCondition(1000, () => {
-    //     logger.info('当前app', app.id, app.threadStatus);
-    //     var isOK = false
-    //     if (app.id === -1 || (app.childProcess === undefined && app.status === 0)) {
-    //         isOK = true;
-    //     } else {
-    //         var pid = app.childProcess.pid
-    //         logger.info(`当前pid:${pid}`);
-    //         //1 通过指令查询是否存在
-    //         var pidIsOK = false
-    //         execSync(`sudo ps -p ${pid} > /dev/null && echo "true" || echo "false"`, (error, stdout, stderr) => {
-    //             if (error) {
-    //                 logger.error(`进程${pid} 查询失败: ${error}`);
-    //                 return
-    //             }
-    //             logger.info(`进程查询结果:${stdout}`);
-    //             if (stdout === "true") {
-    //                 pidIsOK = true
-    //             }
-    //         });
-    //
-    //         if (pidIsOK) {
-    //             if (killCount === 0) {
-    //                 killCount = 1
-    //                 execSync(`sudo kill ${pid}`, (error, stdout, stderr) => {
-    //                     if (error) {
-    //                         logger.error(`进程${pid} 杀死失败: ${error}`);
-    //                     }
-    //                     logger.info(`进程${pid} 杀死成功`);
-    //                     logger.info(`当前app:`, app);
-    //                     app.threadStatus = RobotStatus.STOP_PENDING
-    //                     robotStatus(app)
-    //                     isOK = true
-    //                 });
-    //             } else {
-    //                 logger.info(`灭杀指令已发送..等待结果!`);
-    //             }
-    //         }else{
-    //             isOK = true
-    //         }
-    //     }
-    //
-    //     if (isOK) {
-    //         return true
-    //     }
-    //     return false
-    // });
-
-    //启动
-    // run(param)
     app.restartStatus = 0
     logger.info(`重启完成!!!!!`);
 }