修改任务队列执行日志

This commit is contained in:
whyour
2023-10-06 02:34:40 +08:00
parent 9d55cb108c
commit ec5b885476
16 changed files with 162 additions and 78 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ export default (app: Router) => {
};
const filePath = join(config.logPath, path, filename);
if (type === 'directory') {
emptyDir(filePath);
await emptyDir(filePath);
} else {
fs.unlinkSync(filePath);
}
+4 -3
View File
@@ -183,7 +183,7 @@ export default (app: Router) => {
};
const filePath = join(config.scriptPath, path, filename);
if (type === 'directory') {
emptyDir(filePath);
await emptyDir(filePath);
} else {
fs.unlinkSync(filePath);
}
@@ -260,7 +260,6 @@ export default (app: Router) => {
}),
}),
async (req: Request, res: Response, next: NextFunction) => {
const logger: Logger = Container.get('logger');
try {
let { filename, path, pid } = req.body;
const { name, ext } = parse(filename);
@@ -269,7 +268,9 @@ export default (app: Router) => {
const scriptService = Container.get(ScriptService);
const result = await scriptService.stopScript(filePath, pid);
emptyDir(logPath);
setTimeout(() => {
emptyDir(logPath);
}, 3000);
res.send(result);
} catch (e) {
return next(e);