Add SIGINT handler
This commit is contained in:
parent
f39c4a7ee1
commit
01c647d675
20
index.js
20
index.js
|
@ -22,4 +22,22 @@ async function runModules() {
|
||||||
await require(`./util/${file}`).run();
|
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();
|
||||||
|
});
|
Loading…
Reference in a new issue