Add SIGINT handler
This commit is contained in:
parent
f39c4a7ee1
commit
01c647d675
18
index.js
18
index.js
|
@ -23,3 +23,21 @@ async function 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();
|
||||
});
|
Loading…
Reference in a new issue