We have been using Hangfire for a while in a load balanced cluster of web servers. We back it with a SQL server and it has worked well for us. Typically we fire off jobs to execute immediately or in the future and Hangfire has handled it well. But now I’m looking at periodic jobs and I’m trying to figure out the best way to manage them.
I would like for when the server starts up to read a configuration file and start a periodic job if it isn’t already running. But how do I check to see if it is already running? I could remove the job and re-add it. But then since I have multiple web servers, each of them will do this, removing existing jobs and adding them. This doesn’t feel right but I’m not sure what the right solution is. How should recurring jobs be scheduled and ensured they are scheduled properly?