Skip to content

Commit

Permalink
修复unix系统中子进程未结束问题;
Browse files Browse the repository at this point in the history
  • Loading branch information
cxOrz committed Apr 14, 2023
1 parent bc18318 commit c213e87
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions apps/server/src/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ async function handleMsg(this: CQ, data: string) {
}
}

process.on('SIGINT', () => {
process.exit(0);
});

// 开始运行
(async () => {
let params: any = {};
Expand Down
6 changes: 4 additions & 2 deletions apps/server/src/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,12 @@ app.use(async (ctx, next) => {
});
app.use(router.routes());

process.on('exit', () => {
// Ctrl + C 终止程序
process.on('SIGINT', () => {
processMap.forEach((pcs) => {
pcs.kill('SIGKILL');
pcs.kill('SIGINT');
});
process.exit();
});

// 若在服务器,直接运行
Expand Down

0 comments on commit c213e87

Please sign in to comment.