After publishing ASP MVC application, Hangfire Dashboard says, that it has no active servers. Tried to restart, rebuild, remove Hangfire's tables in DB - no success. OWIN Startup class:
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
app.MapSignalR();
GlobalConfiguration.Configuration
.UseSqlServerStorage(@"HangfireStorage");
var options = new BackgroundJobServerOptions
{
Queues = new[] { "critical", "default" }
};
app.UseHangfireServer(options);
app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
AuthorizationFilters = new[] { new MyRestrictiveAuthorizationFilter() }
});
var hangfireUpdatingCron = ConfigurationManager.AppSettings["HangfireUpdatingPlayersCron"];
var hangfireUpdatingLeagueMatchesCron = ConfigurationManager.AppSettings["HangfireUpdatingLeagueMatchesCron"];
BackgroundJob.Enqueue(() => SteamParser.ResetAllUpdatings());
BackgroundJob.Enqueue(() => SteamParser.UpdateAllPlayers());
RecurringJob.AddOrUpdate(() => SteamParser.UpdateAllPlayers(), hangfireUpdatingCron);
RecurringJob.AddOrUpdate(() => SteamParser.UpdateLeagueMatches(), hangfireUpdatingLeagueMatchesCron);
}
}
Ok, working for me now. Perhaps your situation has a similar solution. Paraphrasing from my update to that issue:
My problem was specifically that I was running multiple applications in the same app pool, so the default "machinename:PID" naming scheme was not unique. But each app was pointed to its own separate database. So there was a race on startup/deploy and only one of the apps got to claim the single
BackgroundJobServer
as its own. But no errors logged; everything looked fine.The answer is in the docs: "Since the defaults values provide uniqueness only on a process level, you should to handle it manually, if you want to run different server instances inside the same process"
But the important point is that this situation includes multiple applications running under the same app pool, which is a single process.
Furthermore, when I attempted to implement the change suggested in the doc (setting a unique
BackgroundJobServerOptions.ServerName
), it errored out due to the maxlength problem mentioned in this comment. My solution was to use something shorter than a GUID for uniqueness. In my case, I used the application's name.