소스 검색

日志查询bug

hl 10 달 전
부모
커밋
460a6ab64c
2개의 변경된 파일2개의 추가작업 그리고 11개의 파일을 삭제
  1. 0 1
      src/robot.js
  2. 2 10
      src/web.js

+ 0 - 1
src/robot.js

@@ -44,7 +44,6 @@ function getApp(key) {
         threadStartTime: -1,
         status: 0,
         restartStatus: 0,
-        isFilePath:false,
 
     }
     // logger.info(appMap, appMap.has(key));

+ 2 - 10
src/web.js

@@ -76,19 +76,17 @@ function init() {
     app.get('/isOK', (req, res) => {
         res.send({'code': 200, 'data': true, "message": "SUCCESS"});
     });
-    app.get('/logs', (req, res) => {
+    app.get('/logs', async (req, res) => {
         // 获取发送过来的信息(请求体的数据)
         const param = req.query;
         const n = param.n
         const id = param.id
 
         var port = -1;
-        var isFilePath = false;
         robot.appMap.forEach((value, key) => {
             // logger.info(JSON.stringify(value))
             if (value.id + "" === id + "") {
                 port = value.port
-                isFilePath = value.isFilePath
             }
         })
 
@@ -97,15 +95,9 @@ function init() {
             var logPath = "./logs" + port
             // 将相对路径转换为绝对路径
             const directoryPath = path.resolve(logPath);
-            if (isFilePath === false) {
-                if (file.checkPathSync(directoryPath)) {
-                   var app_demo =  robot.getApp(id + "");
-                    app_demo.isFilePath = true
-                }
-            }
+            await file.checkPathSync(directoryPath)
 
             logger.info(`日志相对地址:${logPath}`)
-
             file.getLastFile(logPath, 10, (fileNameList) => {
                 logger.info('??1:', fileNameList);
                 result = file.readLastNLines(logPath, fileNameList, n);