修复退出调试自动删除调试日志目录

This commit is contained in:
whyour
2023-08-22 22:18:18 +08:00
parent a8174e89be
commit 40e8041401
11 changed files with 36 additions and 23 deletions
+2
View File
@@ -265,9 +265,11 @@ export default (app: Router) => {
let { filename, path, pid } = req.body;
const { name, ext } = parse(filename);
const filePath = join(config.scriptPath, path, `${name}.swap${ext}`);
const logPath = join(config.logPath, path, `${name}.swap`);
const scriptService = Container.get(ScriptService);
const result = await scriptService.stopScript(filePath, pid);
emptyDir(logPath);
res.send(result);
} catch (e) {
return next(e);
+1 -2
View File
@@ -53,10 +53,9 @@ export default class ScriptService {
}
public async stopScript(filePath: string, pid: number) {
let str = '';
if (!pid) {
const relativePath = path.relative(config.scriptPath, filePath);
pid = await getPid(`${TASK_COMMAND} -l ${relativePath} now`);
pid = await getPid(`${TASK_COMMAND} -l ${relativePath} now`) as number;
}
try {
await killTask(pid);