Hangfire 在同一台服务器上显示两个实例 运行 v.1.5.3 - 导致错误

Hangfire shows two instances running on the same server v.1.5.3 - Leads to errors

我遵循了指定的文档 here to make the application always running and enable Service Auto-start. For configuration I used the documentation specified here 并且在这个应用程序中我使用的是 Hangfire 版本 1.5.3。我在同一台服务器上还有另外两个 Hangfire 应用程序 运行,一个使用 Hangfire v.1.4.1,另一个使用 1.4.5。这两个都可以完美地工作。每个应用程序都在它自己的应用程序池下运行,并且代码没有区别。

无法运行的应用程序在端口号后添加了一个 GUID,如下图所示。此应用程序有时不会自动启动,我认为这与两个服务器实例有关。

我知道 Hangfire 已经用 ServerName 修改了一些东西,因为如果你使用 "BackgroundJobServerOptions" 和 "ServerName" 变量你会得到过时的消息:

"Server Id is auto-generated now, and this option does not make sense anymore. Will be removed in 2.0.0."

有没有人遇到过这个问题并设法解决了?

注意:我没有在任何应用程序中使用 BackgroundJobServerOptions,我已尝试重新启动服务器。

两个有效的应用程序:

找到问题了。似乎在版本 1.5.3 中,可能是 1.5 <,如果您也在 Global.asax 中注册了应用程序启动,则不应在 OWIN 启动 class 中使用 app.UseHangfireServer()。当我注释掉下面的代码时,一切又开始工作了。

public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);

            //GlobalConfiguration.Configuration.UseSqlServerStorage("DefaultConnection");
            //app.UseHangfireServer();
        }
    }

更新:

我正在学习本教程:

http://docs.hangfire.io/en/latest/deployment-to-production/making-aspnet-app-always-running.html

Global.asax.cs:

protected void Application_Start(object sender, EventArgs e)
{
    HangfireBootstrapper.Instance.Start();
}

protected void Application_End(object sender, EventArgs e)
{
    HangfireBootstrapper.Instance.Stop();
}