From 25fe92ffe064e42e3abb5c0b5188856799509e0a Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Fri, 7 Jul 2023 01:11:01 -0600 Subject: [PATCH] feat: added exit handler --- src2/app.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src2/app.ts b/src2/app.ts index 5e75e4b..5ca5c13 100644 --- a/src2/app.ts +++ b/src2/app.ts @@ -95,3 +95,14 @@ log.blank() // Start program main().catch(() => process.exit(1)); + +// Exit tasks +['SIGINT', 'SIGTERM'].forEach((signal) => process.addListener(signal as any, () => { + + // Hide ^C in console output + process.stdout.write('\r'); + + // Log then exit + log.info('Exiting', `received ${signal}`); + process.exit(); +}));