Add SIGINT handler

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

View file

@ -22,4 +22,22 @@ async function runModules() {
await require(`./util/${file}`).run();
}
}
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();
});