Skip to content

Commit

Permalink
fix: kill child process when parent exit
Browse files Browse the repository at this point in the history
  • Loading branch information
fengkx committed Jan 19, 2022
1 parent 8f10b0e commit 2ea489a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ async function startFetchProcess(restartTime: number): Promise<void> {
const child = fork(fetchJS, [], {
execArgv
});
process.once('exit', () => {
child.kill(9);
});
child.on('message', function (message: Message | string) {
if (typeof message === 'string') logger.info(message);
else if (isSuccess(message)) {
Expand Down

0 comments on commit 2ea489a

Please # to comment.