const redis = require('redis');
const REDIS_PORT = process.env.REDIS_PORT || 6379
const client = redis.createClient(REDIS_PORT)
const connectRedis = async () => {
await client.PING().then(
async () => {
// what to run if the PING is successful, which also means the server is up.
console.log("server is running...")
},
async () => {
// what to run if the PING is unsuccessful, which also means the server is down.
console.log("server is not running, trying to connect...")
client.on('error', (err) => console.log('Redis Client Error', err));
await client.connect();
})
return
}