I am using nestjs with bull queues. I am using @nestjs/bull package and everything works fine. But if for some reason, my application is not connected to redis, I don't get any error. The application runs properly, doesn't get any errors but doesn't process the queues. It just hangs. Even the promise doesn't get resolved, it just hangs. But if my redis application is connected properly, then everything works. Now, I want to see whether the redis server is successfully connected to my application or not every time I start my server.
How can I do that?
I have been searching for that for a while now but couldn't get anything from google. Any information or resource will be helpful. Thanks.
It is possible to get access to the Redis client over the Queue instance
In this way you can access Redis client instance which has the
statusproperty oftype RedisStatus = "wait" | "reconnecting" | "connecting" | "connect" | "ready" | "close" | "end";The queue we refer to needs to be imported into a module
You can check if Redis is available at startup by the service below. Note:
AppModuledelayfunction to wait one second before checking theRedisState. The logic can be extended to fit your needs.So when you start your app you will get ->
Or ->