How does Hangfire restart mechanism behave during web deploys and site restarts?

recurring
aspnetcore
sql-server
Tags: #<Tag:0x00007f499b2582d0> #<Tag:0x00007f499b2580a0> #<Tag:0x00007f499b25f328>

#1

Asp.Net Core 2.2.0
Sql Server 2016

Hangfire advertised feature is that scheduled tasks survive across process boundaries.

In practice I’ve noticed that whenever a Hangfire-enabled app process ends ( for any reason ) Hangfire by some mechanism immediately restarts it.

This can easily be demonstrated by Task Monitor > MyApp.exe > End Task : immediately a new MyApp.exe will be spun-up.

I supposed this is a reasonable strategy for background task monitor and executor meant to be integrated into an app , rather than run as a distinct service.

But I’m wondering about the implications for deploys.

  1. How does a Hangfire respond to aplication executable being overcopied with a new version ?
  2. For a Windows Service, how does Hangfire respond to stop/start service ?
  3. For an IIS hosted Asp.Net Core app, how does Hangfire respond stop/start site/app-pool ?

I’m also wondering about situations where one would legitimately want the process to completely end (including Hangfire stop processing all scheduled tasks) - possibly in response to a production incident or during a dev-test or QA scenario.


#2

Hangfire doesn’t have such a feature where it can monitor and respawn the process. Maybe you’re running your application as a Windows Service where Windows Service can restart a service up to n number of times if configured accordingly.


#3

This is a .Net Core 2.2 Web API application so the output type is Console Application.

Very strange something is continually restarting MyApp.exe