We left Russia. We are against aggression and war with Ukraine. It is a tragedy for our nations, it is a nightmare

How to configure HangFire server on specific server?

Hi, Greetings!
I’m new to the HangFire forum and just started learning about HangFire which we would like to implement recurring background jobs in our ASP.NET WebAPI application (.NET Framework 4.8). we have created a POC in our local environment and got what we are looking for. I would like to understand how we can implement in the production and specifically, we are looking to configure Hangfire server on single server of the cluster. (eg. we have 10 prod servers but would like to configure to schedule background jobs to run only on one server even though we deploy code in all servers). Is this a good idea to or do we have any cons with this implementation? Is anyone implemented it already? any helpful documentation or examples are much appreciated.
Please advise and Thanks a lot in advance!


Have an environment variable on the server you want to run it on. In your app, check for that environment variable. Only setup Hangfire server if the environment variable is found.