mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-25 09:00:58 +03:00
Add logs (#4977)
* Add better logs to build chatflow functino * Add connection logs to queue manager * Redact credentials * Add connection logs for redis pub-sub * add more loggings around queue --------- Co-authored-by: Henry <hzj94@hotmail.com>
This commit is contained in:
@@ -12,6 +12,7 @@ import { BullMQAdapter } from '@bull-board/api/bullMQAdapter'
|
||||
import { Express } from 'express'
|
||||
import { UsageCacheManager } from '../UsageCacheManager'
|
||||
import { ExpressAdapter } from '@bull-board/express'
|
||||
import logger from '../utils/logger'
|
||||
|
||||
const QUEUE_NAME = process.env.QUEUE_NAME || 'flowise-queue'
|
||||
|
||||
@@ -25,30 +26,57 @@ export class QueueManager {
|
||||
private predictionQueueEventsProducer?: QueueEventsProducer
|
||||
|
||||
private constructor() {
|
||||
let tlsOpts = undefined
|
||||
if (process.env.REDIS_URL && process.env.REDIS_URL.startsWith('rediss://')) {
|
||||
tlsOpts = {
|
||||
rejectUnauthorized: false
|
||||
if (process.env.REDIS_URL) {
|
||||
let tlsOpts = undefined
|
||||
if (process.env.REDIS_URL.startsWith('rediss://')) {
|
||||
tlsOpts = {
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
} else if (process.env.REDIS_TLS === 'true') {
|
||||
tlsOpts = {
|
||||
cert: process.env.REDIS_CERT ? Buffer.from(process.env.REDIS_CERT, 'base64') : undefined,
|
||||
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
|
||||
}
|
||||
}
|
||||
} else if (process.env.REDIS_TLS === 'true') {
|
||||
tlsOpts = {
|
||||
cert: process.env.REDIS_CERT ? Buffer.from(process.env.REDIS_CERT, 'base64') : undefined,
|
||||
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
|
||||
this.connection = {
|
||||
url: process.env.REDIS_URL,
|
||||
tls: tlsOpts,
|
||||
enableReadyCheck: true,
|
||||
keepAlive:
|
||||
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
|
||||
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
|
||||
: undefined
|
||||
}
|
||||
}
|
||||
this.connection = {
|
||||
url: process.env.REDIS_URL || undefined,
|
||||
host: process.env.REDIS_HOST || 'localhost',
|
||||
port: parseInt(process.env.REDIS_PORT || '6379'),
|
||||
username: process.env.REDIS_USERNAME || undefined,
|
||||
password: process.env.REDIS_PASSWORD || undefined,
|
||||
tls: tlsOpts,
|
||||
enableReadyCheck: true,
|
||||
keepAlive:
|
||||
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
|
||||
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
|
||||
: undefined
|
||||
logger.info(
|
||||
`[QueueManager] Connecting to Redis using URL: ${process.env.REDIS_URL.replace(/\/\/[^:]+:[^@]+@/, '//[CREDENTIALS]@')}`
|
||||
)
|
||||
} else {
|
||||
let tlsOpts = undefined
|
||||
if (process.env.REDIS_TLS === 'true') {
|
||||
tlsOpts = {
|
||||
cert: process.env.REDIS_CERT ? Buffer.from(process.env.REDIS_CERT, 'base64') : undefined,
|
||||
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
|
||||
}
|
||||
}
|
||||
this.connection = {
|
||||
host: process.env.REDIS_HOST || 'localhost',
|
||||
port: parseInt(process.env.REDIS_PORT || '6379'),
|
||||
username: process.env.REDIS_USERNAME || undefined,
|
||||
password: process.env.REDIS_PASSWORD || undefined,
|
||||
tls: tlsOpts,
|
||||
enableReadyCheck: true,
|
||||
keepAlive:
|
||||
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
|
||||
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
|
||||
: undefined
|
||||
}
|
||||
logger.info(
|
||||
`[QueueManager] Connecting to Redis using host:port: ${process.env.REDIS_HOST || 'localhost'}:${
|
||||
process.env.REDIS_PORT || '6379'
|
||||
}`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +148,16 @@ export class QueueManager {
|
||||
usageCacheManager
|
||||
})
|
||||
this.registerQueue('prediction', predictionQueue)
|
||||
|
||||
// Add connection event logging for prediction queue
|
||||
if (predictionQueue.getQueue().opts.connection) {
|
||||
const connInfo = predictionQueue.getQueue().opts.connection || {}
|
||||
const connInfoString = JSON.stringify(connInfo)
|
||||
.replace(/"username":"[^"]*"/g, '"username":"[REDACTED]"')
|
||||
.replace(/"password":"[^"]*"/g, '"password":"[REDACTED]"')
|
||||
logger.info(`[QueueManager] Prediction queue connected to Redis: ${connInfoString}`)
|
||||
}
|
||||
|
||||
this.predictionQueueEventsProducer = new QueueEventsProducer(predictionQueue.getQueueName(), {
|
||||
connection: this.connection
|
||||
})
|
||||
@@ -134,6 +172,15 @@ export class QueueManager {
|
||||
})
|
||||
this.registerQueue('upsert', upsertionQueue)
|
||||
|
||||
// Add connection event logging for upsert queue
|
||||
if (upsertionQueue.getQueue().opts.connection) {
|
||||
const connInfo = upsertionQueue.getQueue().opts.connection || {}
|
||||
const connInfoString = JSON.stringify(connInfo)
|
||||
.replace(/"username":"[^"]*"/g, '"username":"[REDACTED]"')
|
||||
.replace(/"password":"[^"]*"/g, '"password":"[REDACTED]"')
|
||||
logger.info(`[QueueManager] Upsert queue connected to Redis: ${connInfoString}`)
|
||||
}
|
||||
|
||||
if (serverAdapter) {
|
||||
createBullBoard({
|
||||
queues: [new BullMQAdapter(predictionQueue.getQueue()), new BullMQAdapter(upsertionQueue.getQueue())],
|
||||
|
||||
Reference in New Issue
Block a user