redis not req for local dev
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
import { createClient, RedisClientType } from "redis";
|
||||
|
||||
export const pubClient: RedisClientType = createClient({
|
||||
url: `redis://${process.env.REDIS_HOST}:${process.env.REDIS_PORT}`,
|
||||
url: `redis://${process.env.REDIS_HOST || "localhost"}:${process.env.REDIS_PORT || 6379}`,
|
||||
});
|
||||
export const subClient: RedisClientType = pubClient.duplicate();
|
||||
|
||||
Promise.all([pubClient.connect(), subClient.connect()]).then(() => {
|
||||
console.log("Redis connected");
|
||||
});
|
||||
if (!process.env.REDIS_HOST || !process.env.REDIS_PORT) {
|
||||
console.warn("REDIS_HOST or REDIS_PORT not set, skipping Redis connection");
|
||||
} else {
|
||||
Promise.all([pubClient.connect(), subClient.connect()]).then(() => {
|
||||
console.log("Redis connected");
|
||||
});
|
||||
}
|
||||
|
||||
pubClient.on("error", (err) => console.log("Redis Client Error", err));
|
||||
subClient.on("error", (err) => console.log("Redis Client Error", err));
|
||||
|
||||
Reference in New Issue
Block a user