Skip to content

Commit

Permalink
Handle ioredis connection events
Browse files Browse the repository at this point in the history
  • Loading branch information
wjt committed Sep 30, 2024
1 parent 2e6e2ab commit 8f5cd59
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions util/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ exports = module.exports = {
},
});

redis.on('connect', () => {
config.logger.info('Connected to Redis server');
});
redis.on('ready', () => {
config.logger.info('Redis connection ready');
});
redis.on('reconnecting', (delay) => {
config.logger.info(`Reconnecting to ${config.redis_host}:${config.redis_port} in ${delay} ms`);
});
redis.on('close', () => {
config.logger.info('Disconnected from Redis server');
});
redis.on('error', (err) => {
config.logger.error('Error connecting to Redis server: ' + err);
});

callback(redis);
},
};

0 comments on commit 8f5cd59

Please sign in to comment.