Can't get hangfire to re-run all processing jobs after server shut down

Hi,

I new to hangfire, so sorry if this is something obvious. :slight_smile:

So, I am testing the following case: I have jobs running on my application and for some reason, I need to kill my application server. So, I kill the application server, turn in back up again and I need the jobs that were in the processing state before the application server shut down to be re-runed automatically. From my research, I got to the conclusion that hangfire handles this out of the box, without requiring me to set up some specific configuration, but it doesn’t.

From the dashboard, I see my job, but it says that it is aborted because the hangfire server was killed, which makes sense. On app startup I am creating a new hangfire server, every time (UseHangfireServer method does this) and when the application gets to the point where it should re-run the job, it can’t because hangfire is running in the context of the newly created server and the old one stays idle. I think this is the problem, but I am not sure. As I said, my understanding of hangfire is not that great. :slight_smile:

Is there something that I should do in order to reuse my old hangfire server (from my understanding that should do the trick) ? Maybe some kind of configuration that I had missed…

Is this, realy the source of my problem or I am looking at the wrong place?

Hi @Iliyan_Tanev, what storage are you using for your background jobs?

Hi @odinserj, I am using SQL Server.

So what version are you using? I’m asking, because in Hangfire ≥ 1.5.0 with SQL Server, background job re-queue should be immediate after server shutdown, but in earlier versions you should wait 5-10 minutes before automatic re-queueing. Can you please also add some screenshots of your job to see what’s exactly going on?

Hi,

Thank you for the response!

I was using 1.41. I upgraded to 1.68 and now it seems to be working as expected.