mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-11 18:08:27 +00:00
* feat: remove trigger and run base on bullmq * fix: telemetry and trigger deploymen * feat: add Ollama container and update ingestion status for unchanged documents * feat: add logger to bullmq workers * 1. Remove chat and deep-search from trigger 2. Add ai/sdk for chat UI 3. Added a better model manager * refactor: simplify clustered graph query and add stop conditions for AI responses * fix: streaming * fix: docker docs --------- Co-authored-by: Manoj <saimanoj58@gmail.com>
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import Redis, { type RedisOptions } from "ioredis";
|
|
|
|
let redisConnection: Redis | null = null;
|
|
|
|
/**
|
|
* Get or create a Redis connection for BullMQ
|
|
* This connection is shared across all queues and workers
|
|
*/
|
|
export function getRedisConnection() {
|
|
if (redisConnection) {
|
|
return redisConnection;
|
|
}
|
|
|
|
// Dynamically import ioredis only when needed
|
|
|
|
const redisConfig: RedisOptions = {
|
|
host: process.env.REDIS_HOST,
|
|
port: parseInt(process.env.REDIS_PORT as string),
|
|
maxRetriesPerRequest: null, // Required for BullMQ
|
|
enableReadyCheck: false, // Required for BullMQ
|
|
};
|
|
|
|
// Add TLS configuration if not disabled
|
|
if (!process.env.REDIS_TLS_DISABLED) {
|
|
redisConfig.tls = {};
|
|
}
|
|
|
|
redisConnection = new Redis(redisConfig);
|
|
|
|
redisConnection.on("error", (error) => {
|
|
console.error("Redis connection error:", error);
|
|
});
|
|
|
|
redisConnection.on("connect", () => {
|
|
console.log("Redis connected successfully");
|
|
});
|
|
|
|
return redisConnection;
|
|
}
|
|
|
|
/**
|
|
* Close the Redis connection (useful for graceful shutdown)
|
|
*/
|
|
export async function closeRedisConnection(): Promise<void> {
|
|
if (redisConnection) {
|
|
await redisConnection.quit();
|
|
redisConnection = null;
|
|
}
|
|
}
|