17 lines
548 B
TypeScript
17 lines
548 B
TypeScript
|
|
function parseRedisUrl(url: string): { host: string; port: number; password?: string } {
|
||
|
|
const parsed = new URL(url);
|
||
|
|
return {
|
||
|
|
host: parsed.hostname,
|
||
|
|
port: parseInt(parsed.port) || 6379,
|
||
|
|
password: parsed.password || undefined,
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
// BullMQ creates its own IORedis connections from these options.
|
||
|
|
// maxRetriesPerRequest: null is required for workers.
|
||
|
|
export const redisConnectionOpts = {
|
||
|
|
...parseRedisUrl(process.env.REDIS_URL || "redis://localhost:6379"),
|
||
|
|
maxRetriesPerRequest: null as null,
|
||
|
|
enableReadyCheck: false,
|
||
|
|
};
|