mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
Fix: Add keep-alive options to Redis clients to prevent idle timeouts and socket closing. (#4377)
* redis keepalive mechanism for all redis * removed offline queue commands * Simplified changes for consistency. Added REDIS_KEEP_ALIVE env variable. * update redis socket alive env variable * lint fix --------- Co-authored-by: Henry <hzj94@hotmail.com> Co-authored-by: Henry Heng <henryheng@flowiseai.com>
This commit is contained in:
@@ -12,7 +12,12 @@ export class CachePool {
|
||||
constructor() {
|
||||
if (process.env.MODE === MODE.QUEUE) {
|
||||
if (process.env.REDIS_URL) {
|
||||
this.redisClient = new Redis(process.env.REDIS_URL)
|
||||
this.redisClient = new Redis(process.env.REDIS_URL, {
|
||||
keepAlive:
|
||||
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
|
||||
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
|
||||
: undefined
|
||||
})
|
||||
} else {
|
||||
this.redisClient = new Redis({
|
||||
host: process.env.REDIS_HOST || 'localhost',
|
||||
@@ -26,6 +31,10 @@ export class CachePool {
|
||||
key: process.env.REDIS_KEY ? Buffer.from(process.env.REDIS_KEY, 'base64') : undefined,
|
||||
ca: process.env.REDIS_CA ? Buffer.from(process.env.REDIS_CA, 'base64') : undefined
|
||||
}
|
||||
: undefined,
|
||||
keepAlive:
|
||||
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
|
||||
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
|
||||
: undefined
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user