hl 10 месяцев назад
Родитель
Сommit
d8b75fc2e2
1 измененных файлов с 14 добавлено и 13 удалено
  1. 14 13
      src/web.js

+ 14 - 13
src/web.js

@@ -44,15 +44,15 @@ function init() {
         res.send('is OK!');
     });
     app.get('/robotList', (req, res) => {
-       var map = robot.getAppMap()
-        var list  =new Array();
+        var map = robot.getAppMap()
+        var list = new Array();
         robot.appMap.forEach((value, key) => {
             // str.set(key,JSON.stringify(value))
             list.push({
                 id: value.id,
-                nowBalance: value.nowBalance+"",
+                nowBalance: value.nowBalance + "",
                 messlist: value.messlist,
-                threadStatus:value.threadStatus,
+                threadStatus: value.threadStatus,
                 errorMessage: value.errorMessage,
                 threadStartTime: value.threadStartTime,
                 status: value.status,
@@ -95,15 +95,16 @@ function init() {
             var logPath = "./logs" + port
             // 将相对路径转换为绝对路径
             const directoryPath = path.resolve(logPath);
-            file.checkPathSync(directoryPath)
-            logger.info(`日志相对地址:${logPath}`)
-
-            file.getLastFile(logPath, 10, (fileNameList) => {
-                logger.info('??1:', fileNameList);
-                result = file.readLastNLines(logPath, fileNameList, n);
-                // logger.info('?????:', result);
-                res.send({'code': 200, 'data': result, "message": "SUCCESS"});
-            });
+            if (file.checkPathSync(directoryPath)) {
+                logger.info(`日志相对地址:${logPath}`)
+
+                file.getLastFile(logPath, 10, (fileNameList) => {
+                    logger.info('??1:', fileNameList);
+                    result = file.readLastNLines(logPath, fileNameList, n);
+                    // logger.info('?????:', result);
+                    res.send({'code': 200, 'data': result, "message": "SUCCESS"});
+                });
+            }
         } else {
             res.send({'code': 200, 'data': result, "message": "SUCCESS"});
         }