const handleTermination = async () => {
Logger.info('Terminating bot...');
try {
client.removeAllListeners();
await closeMongooseConnection();
await client.destroy();
Logger.info('Cleanup complete. Exiting...');
process.exit(0);
} catch (error) {
Logger.error('Error during termination:', error);
process.exit(1);
}
};
process.on('SIGINT', handleTermination);
process.on('SIGTERM', handleTermination);
const handleTermination = async () => {
Logger.info('Terminating bot...');
try {
client.removeAllListeners();
await closeMongooseConnection();
await client.destroy();
Logger.info('Cleanup complete. Exiting...');
process.exit(0);
} catch (error) {
Logger.error('Error during termination:', error);
process.exit(1);
}
};
process.on('SIGINT', handleTermination);
process.on('SIGTERM', handleTermination);