Search code examples
asp.net-corehangfire

Can Hangfire schedule jobs do this?


I am evaluating Hangfire for an upcoming ASP.net Core project that has several scheduled and reoccurring tasks that need to execute independently of users clicking on web pages. I know that HangFire can do this if the web application is started because a request has come in. I need to know whether or not HangFire can execute a scheduled task between being rebooted and the first web request coming in.

Example: Web server is rebooted at 11pm, and no web requests will come in to cause the web server to spin up until 5am the next morning. A scheduled task needs to be performed at 1AM. Will Hangfire execute this task even though the web application hasn't been started by an incoming request?

If it can, is there a certain setup I need to do to allow this?

Details, if needed: We are going to be using Kestrel hosted in a windows service and sitting behind an NGINX reverse proxy. This setup could be modified if needed to make HangFire meet this requirement.


Solution

  • When running under IIS it would be a real problem, see Making ASP.NET application always running

    But it should not be problem for ASP.NET CORE with kestrel, see

    It is not necessary for ASP.NET Core, because application is exposed by a console application that it already always on – there are no timeouts, no suspends and other optimization techniques yet. All you need to do is to use supervisor as written in the official docs for Linux, or use Windows Service with automatic start time, when running on Windows.