|
@@ -100,41 +100,40 @@ function cacheLogs() {
|
|
|
setInterval(() => {
|
|
|
// logger.info('当前2',robot.appMap);
|
|
|
robot.appMap.forEach((value, key) => {
|
|
|
- new Promise((resolve, reject) => {
|
|
|
- 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, async (fileNameList, _) => {
|
|
|
- logger.info('-----文件:', fileNameList);
|
|
|
- let result = await file.getLatestLogEntries(logPath, fileNameList.reverse(), n);
|
|
|
- if (messlist.length === 0) {
|
|
|
- value.messlist = result
|
|
|
- } else {
|
|
|
- if (messlist[0] !== result[0]) {
|
|
|
- value.messlist = result
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- } catch (e) {
|
|
|
- logger.info('异步缓存日志异常~~', e);
|
|
|
- }
|
|
|
+ zz(value)
|
|
|
+ });
|
|
|
+ }, 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, async (fileNameList, _) => {
|
|
|
+ logger.info('-----文件:', fileNameList);
|
|
|
+ let result = await file.getLatestLogEntries(logPath, fileNameList.reverse(), n);
|
|
|
+ if (messlist.length === 0) {
|
|
|
+ value.messlist = result
|
|
|
+ } else {
|
|
|
+ if (messlist[0] !== result[0]) {
|
|
|
+ value.messlist = result
|
|
|
+ }
|
|
|
}
|
|
|
- resolve()
|
|
|
- }).then(r => {
|
|
|
- logger.info('异步缓存日志异常~~失败');
|
|
|
});
|
|
|
- });
|
|
|
- }, intervalInMilliseconds);
|
|
|
+ } catch (e) {
|
|
|
+ logger.info('异步缓存日志异常~~', e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function cachePredictorState() {
|