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

This commit is contained in:
whyour
2022-03-26 00:29:42 +08:00
parent 133e9e0e1f
commit da922678a1
3 changed files with 28 additions and 9 deletions
+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 ');