修复定时任务获取日志目录

This commit is contained in:
whyour committed 2022-03-26 00:29:42 +08:00
1 parent d0b13a04cc
commit 0d23f8a962
3 files changed
+28 -9

No files matched your search

+15
View File
@@ -353,6 +353,21 @@ export default class CronService {
return [];
}
if (doc.log_path) {
const relativeDir = `${doc.log_path.replace(/\/[^\/]\..*/, '')}`;
const dir = `${config.logPath}${relativeDir}`;
if (existsSync(dir)) {
let files = await promises.readdir(dir);
return files
.map((x) => ({
filename: x,
directory: relativeDir,
time: fs.statSync(`${dir}/${x}`).mtime.getTime(),
}))
.sort((a, b) => b.time - a.time);
}
}
const [, commandStr, url] = doc.command.split(/ +/);
let logPath = this.getKey(commandStr);
const isQlCommand = doc.command.startsWith('ql ');