Skip to content

Commit

Permalink
feat: handle SIGTERM
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Mar 21, 2023
1 parent 69b2014 commit b0a30a9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/bin/turbowatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,35 @@ const main = async () => {
...turbowatchConfiguration,
});

let terminating = false;

process.once('SIGINT', () => {
if (terminating) {
log.warn('already terminating; ignoring SIGINT');

return;
}

terminating = true;

log.warn('received SIGINT; gracefully terminating');

void turbowatchController.shutdown();
});

process.once('SIGTERM', () => {
if (terminating) {
log.warn('already terminating; ignoring SIGTERM');

return;
}

terminating = true;

log.warn('received SIGTERM; gracefully terminating');

void turbowatchController.shutdown();
});
}
};

Expand Down

0 comments on commit b0a30a9

Please sign in to comment.