Hi,
We are using HangFire 1.6.8 + Pro for a while now in our application (MVC5, .NET) in “testmode” which means one server, one queue one worker and with OWIN. The apllicatin is not “always running” and there is no specific Exit-code of the application for hangfire. Everything works as expected. As developers we restart the app as local several times a day. in our startup we use
int workerThreadCount = 1;
app.UseHangfireServer(new BackgroundJobServerOptions { WorkerCount = workerThreadCount });
We now have the need to distribute the workload and want to use several servers with different queues so we changed the startup like this (OWIN IAppBuilder app):
//Create the Servers
int workerThreadCount = 1;
app.UseHangfireServer(new BackgroundJobServerOptions
{
ServerName = "DEFAULT",
Queues = new string[] { "test", "default" },
WorkerCount = workerThreadCount
});
app.UseHangfireServer(new BackgroundJobServerOptions
{
ServerName = "TEST",
Queues = new string[] { "work", "default" },
WorkerCount = workerThreadCount
});
If I do this, hangfire starts to create a new pair of serverinstances for every restart of the application.
The name is like [servername]:[ID] and the ID changes for every start, so the behaviour is kind of correct. After some time, older versions of the servers disappear after restart, probably because of timeout (heartbeat). I found nothing to stop the backgroundservers.
Jobs that were in the queue of a dying server will be executed by another instance.
I figure that we have to terminate the hangfireservers but where would I do this?
Why is this behaviour? Why is the behaviour different, if only one server is used? It also has an id that changes.