Making Hangfire server always ON in .net core application

@odinserj,
I am using hangfire with .net core application. Recently I found one observation that Hangfire server goes to InActive state when no job is running. I went through hangfire documentation, making-aspnet-app-always-running and forums. I made the server configuration changes like ‘Start mode’ and ‘Idle Timeout’. But not sure how to configure and create ServiceAutoStartProvider class for asp .net core application. i.e. System.Web.Hosting.IProcessHostPreloadClient not supported for .net core applications. I want to keep my hangfire server running always.

1 Like

+1 @odinserj
Below documentation needs updated for asp.net core

+1 @odinserj

I have the same problem with keeping Hangfire always on. Is there a fix for this?

+1

Same problem for me.

I have NOT tried this, but I have seen these articles that might help:

One item mentioned in both of these articles is that “Preload Enabled” needs to be on for the site.

1 Like

Thanks for sharing this. Very helpful.

I have been experimenting with this lately, with an ASP.NET Core (.NET 8.0) app using Hangfire. I found that it also required installing the “Application Initialization Module” on the server that’s running IIS, as described in the second article that I linked above.

I had first tried it without that option, and the Hangfire app just stopped running after about 30 hours. I installed the module mentioned above and I’m continuing to test whether the app keeps running (it hasn’t been another 30 hours yet).

To install this module, read the instructions in the article above. Or, on the server, run Server Manager, click “Local Server” on the left, then, near the top, click “Manage”-“Add Roles and Features”; when you get to the “Select server roles” screen, expand “Web Server (IIS)”, then “Web Server”, then “Application Development”, then check “Application Initialization”, and proceed.

However, even if this latest test seems to work to keep the app always running, I may still set up some separate process that loads a page (not the dashboard) in the app periodically (every hour or few hours), preferably a page that does not require authentication. This could be done with a Windows service on the server, a scheduled task, an external service like Pingdom, or a server/web monitoring application (like PA Server Monitor, which we already use in our organization for monitoring some other internal websites).

1 Like