mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
🐙 fix: Add Redis Ping Interval to Prevent Connection Drops (#7127)
Co-authored-by: Peter Rothlaender <peter.rothlaender@ginkgo.com>
This commit is contained in:
parent
f04f8f53be
commit
a6f0a8244f
1 changed files with 7 additions and 0 deletions
7
api/cache/keyvRedis.js
vendored
7
api/cache/keyvRedis.js
vendored
|
|
@ -75,6 +75,12 @@ if (REDIS_URI && isEnabled(USE_REDIS)) {
|
||||||
} else {
|
} else {
|
||||||
keyvRedis = new KeyvRedis(REDIS_URI, keyvOpts);
|
keyvRedis = new KeyvRedis(REDIS_URI, keyvOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pingInterval = setInterval(() => {
|
||||||
|
logger.debug('KeyvRedis ping');
|
||||||
|
keyvRedis.client.ping().catch(err => logger.error('Redis keep-alive ping failed:', err));
|
||||||
|
}, 5 * 60 * 1000);
|
||||||
|
|
||||||
keyvRedis.on('ready', () => {
|
keyvRedis.on('ready', () => {
|
||||||
logger.info('KeyvRedis connection ready');
|
logger.info('KeyvRedis connection ready');
|
||||||
});
|
});
|
||||||
|
|
@ -85,6 +91,7 @@ if (REDIS_URI && isEnabled(USE_REDIS)) {
|
||||||
logger.info('KeyvRedis connection ended');
|
logger.info('KeyvRedis connection ended');
|
||||||
});
|
});
|
||||||
keyvRedis.on('close', () => {
|
keyvRedis.on('close', () => {
|
||||||
|
clearInterval(pingInterval);
|
||||||
logger.info('KeyvRedis connection closed');
|
logger.info('KeyvRedis connection closed');
|
||||||
});
|
});
|
||||||
keyvRedis.on('error', (err) => logger.error('KeyvRedis connection error:', err));
|
keyvRedis.on('error', (err) => logger.error('KeyvRedis connection error:', err));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue