Add SIGINT handler

This commit is contained in:
Jan 2020-12-27 14:31:47 +01:00
parent f39c4a7ee1
commit 01c647d675

View file

@ -23,3 +23,21 @@ async function runModules() {
} }
} }
runModules(); runModules();
// Destroy client when SIGINT
process.on('SIGINT', async () => {
process.stdin.resume(); // Don't exit immediately
console.log('');
logger.info('SIGINT received.');
try {
await client.destroy();
} catch(e) {
logger.warn('Failed to destroy client');
}
logger.done('Logged out client, exiting.');
process.exit();
});