Przeglądaj źródła

优化日志获取-发现长时间获取会触发100CPU,本次优化尝试解决该问题

hl 2 tygodni temu
rodzic
commit
413c2069b1
1 zmienionych plików z 4 dodań i 4 usunięć
  1. 4 4
      src/web.js

+ 4 - 4
src/web.js

@@ -74,7 +74,7 @@ function init() {
         const n = param.n
         const id = param.id
 
-        var port = -1;
+        var port = 1111;
         robot.appMap.forEach((value, key) => {
             // logger.info(JSON.stringify(value))
             if (value.id + "" === id + "") {
@@ -91,10 +91,10 @@ function init() {
             try {
                 file.checkPathSync(directoryPath)
 
-                file.getLastFile(logPath, 500, async (fileNameList, _) => {
+                file.getLastFile(logPath, 5, async (fileNameList, _) => {
                     // logger.info('cccccccccccccc文件:', fileNameList);
-                    result = await file.readLastNLines(logPath, fileNameList, n);
-                    // result =  await  file.getRecentLogs(logPath,fileNameList.reverse(),n);
+                    // result = await file.readLastNLines(logPath, fileNameList, n);
+                    result =  await  file.getRecentLogs(logPath,fileNameList.reverse(),n);
 
                     // logger.info('?????:', result);
                     res.send({'code': 200, 'data': result, "message": "SUCCESS"});