I've noticed that sometimes in production the background service that runs Hangfire is slow to exit.
I'd like to find out:
What jobs are running when the application receives a stop request
What jobs are still running after, lets say 4seconds* after receiving the stop request.
All my jobs have cancellation tokens, so afaik sending a stop request should allow the app to stop quite quickly.
In production it doesn't sometime, so maybe there are places/jobs where the token is forgotten or not checked withing a large loop etc.
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.
Hiya,
I've noticed that sometimes in production the background service that runs Hangfire is slow to exit. I'd like to find out:
What jobs are still running after, lets say 4seconds* after receiving the stop request.
All my jobs have cancellation tokens, so afaik sending a stop request should allow the app to stop quite quickly. In production it doesn't sometime, so maybe there are places/jobs where the token is forgotten or not checked withing a large loop etc.
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.