mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-02-23 18:51:29 +02:00
feat: handle exit signals
This commit is contained in:
parent
80ee7b3d4e
commit
55660e8c4e
10
src/index.js
10
src/index.js
@ -62,6 +62,16 @@ const logger = require('./lib/logger');
|
|||||||
let config = YAML.parse(fs.readFileSync(path.join(__dirname, 'user/config.yml'), 'utf8'));
|
let config = YAML.parse(fs.readFileSync(path.join(__dirname, 'user/config.yml'), 'utf8'));
|
||||||
let log = logger(config);
|
let log = logger(config);
|
||||||
|
|
||||||
|
function exit(signal) {
|
||||||
|
log.notice(`Received ${signal}`);
|
||||||
|
client.destroy();
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
process.on('SIGTERM', () => exit('SIGTERM'));
|
||||||
|
|
||||||
|
process.on('SIGINT', () => exit('SIGINT'));
|
||||||
|
|
||||||
process.on('uncaughtException', (error, origin) => {
|
process.on('uncaughtException', (error, origin) => {
|
||||||
log.notice(`Discord Tickets v${pkg.version} on Node.js ${process.version} (${process.platform})`);
|
log.notice(`Discord Tickets v${pkg.version} on Node.js ${process.version} (${process.platform})`);
|
||||||
log.warn(origin === 'uncaughtException' ? 'Uncaught exception' : 'Unhandled promise rejection' + ` (${error.name})`);
|
log.warn(origin === 'uncaughtException' ? 'Uncaught exception' : 'Unhandled promise rejection' + ` (${error.name})`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user