Properly shutting down Hangfire in ASP.NET Core environment (eg inject into OnStopping)


#1

Wondering how this is supposed to work.

We call:

app.UseHangfireServer(new BackgroundJobServerOptions { WorkerCount = 4 });

But wonder where we provide the cancellation token so Hangfire stops during shutdown.

In an Azure app service environment, it seems swaps/restarts (?) are getting stalled because Hangfire is still holding the process open.

Thank you