feat: core chunk 8

This commit is contained in:
TrèsAbhi committed 2023-10-14 11:36:48 -05:00
1 parent 01dd7ad9c6
commit ec00bdf9de
14 files changed
+14 -14

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { client } from '../discord/client';
import { discordBlitzDB } from './discordBlitz';
const EXIT_EVENTS = [
'beforeExit',
'exit',
'SIGINT',
'SIGTERM',
'SIGUSR1',
'SIGUSR2',
];
async function cleanup() {
console.log('Cleaning up...');
await Promise.all([discordBlitzDB.$disconnect(), client.destroy()]);
console.log('Gracefully exiting...');
EXIT_EVENTS.forEach((event) => process.off(event, cleanup));
process.exit(0);
}
export function registerProcesses() {
process.on('uncaughtException', console.error);
client.on('error', console.error);
EXIT_EVENTS.forEach((event) => process.on(event, cleanup));
}