|
@@ -100,42 +100,39 @@ function cacheLogs() {
|
|
|
setInterval(() => {
|
|
|
// logger.info('当前2',robot.appMap);
|
|
|
robot.appMap.forEach((value, key) => {
|
|
|
- zz(value)
|
|
|
+ var thisTime = new Date().getTime()
|
|
|
+ let port = value.port
|
|
|
+ let n = 200
|
|
|
+ let messlist = value.messlist
|
|
|
+ if (value.id !== -1 && port !== -1) {
|
|
|
+ logger.info(`~~~缓存日志${value.id}`)
|
|
|
+ try {
|
|
|
+ var logPath = "./logs" + port
|
|
|
+ logger.info(`访问-日志相对目录:${logPath}`)
|
|
|
+ const directoryPath = path.resolve(logPath);
|
|
|
+ file.checkPathSync(directoryPath)
|
|
|
+ file.getLastFile(logPath, 5, (fileNameList, _) => {
|
|
|
+ logger.info('-----文件:', fileNameList);
|
|
|
+ file.getLatestLogEntries(logPath, fileNameList.reverse(), n)
|
|
|
+ .then((result) => {
|
|
|
+ if (messlist.length === 0) {
|
|
|
+ value.messlist = result
|
|
|
+ } else {
|
|
|
+ if (messlist[0] !== result[0]) {
|
|
|
+ value.messlist = result
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ } catch (e) {
|
|
|
+ logger.info('异步缓存日志异常~~', e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
});
|
|
|
}, intervalInMilliseconds);
|
|
|
}
|
|
|
|
|
|
- function zz(value) {
|
|
|
- var thisTime = new Date().getTime()
|
|
|
- let port = value.port
|
|
|
- let n = 200
|
|
|
- let messlist = value.messlist
|
|
|
- if (value.id !== -1 && port !== -1) {
|
|
|
-
|
|
|
- logger.info(`~~~缓存日志${value.id}`)
|
|
|
- try {
|
|
|
- var logPath = "./logs" + port
|
|
|
- logger.info(`访问-日志相对目录:${logPath}`)
|
|
|
- const directoryPath = path.resolve(logPath);
|
|
|
- file.checkPathSync(directoryPath)
|
|
|
- file.getLastFile(logPath, 5, (fileNameList, _) => {
|
|
|
- logger.info('-----文件:', fileNameList);
|
|
|
- file.getLatestLogEntries(logPath, fileNameList.reverse(), n).then((result) =>{
|
|
|
- if (messlist.length === 0) {
|
|
|
- value.messlist = result
|
|
|
- } else {
|
|
|
- if (messlist[0] !== result[0]) {
|
|
|
- value.messlist = result
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- } catch (e) {
|
|
|
- logger.info('异步缓存日志异常~~', e);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
function cachePredictorState() {
|
|
|
// 设置定时器,每隔一定时间(比如每隔5秒)发送一次GET请求
|