HangfireIO / Hangfire

An easy way to perform background job processing in .NET and .NET Core applications. No Windows Service or separate process required
https://www.hangfire.io
Other
9.44k stars 1.71k forks source link

[Question] Hangfire server shutdown is slow, how to debug which jobs are not cancelling? #2328

Open sommmen opened 11 months ago

sommmen commented 11 months ago

Hiya,

I've noticed that sometimes in production the background service that runs Hangfire is slow to exit. I'd like to find out:

I'd like to find out which jobs take long to exit and investigate them. Could somebody provide me some guidance how to log of diagnose slow to exit jobs?

I though about hooking into IHostApplicationLifetime.ApplicationStopping (WindowsServiceLifetime triggers when it receives a stop request) and log each running job. I'd like to do this by just directly asking this to hangfire, without any db calls but i'm not sure how to do this.

luizfbicalho commented 10 months ago

Is there a way to test this? I think I have this problem in one project with the IIS recycle

I would like to understand the shutdown of hangfire in this #1345