1

I have created hangfire recurring jobs in .net core 5.0. I have deployed on IIS with always running opens and webApplication as preload enabled true. on changing the corn expression and restarting the IIS. updated corn expression and execution time is not getting updated in Hangfire database.

Also , Job are not getting process on schedule time unless I open the dashboard.

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236

1 Answers1

1

Implement steps outlined in hangfire documentation.

Step 5b is only necessary when a website contains several child-applications and one wants to start a specific one. Otherwise, steps 1-5b suffice.

Step 5 is persisted in the web.config of your application. To make sure it's not overwritten on deployment, I'd put a web.config with the respective configuration under source control.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />

    <!-- Add this node to web.config -->
    <applicationInitialization doAppInitAfterRestart="true">

      <!-- Only needed when website contains multiple child apps -->
      <add initializationPage='/hangfire',hostname='' />

    <applicationInitialization />
  </system.webServer>
</configuration>

The Azure DevOps Pipelines deploy task uses Web Deploy, which in turn uses the app_offline.htm during deployment. After the app_offline.htm is removed, only the next request restarts the app. So you if you use the app_offline.htm directly or indirectly, you need to fire a warm-up request manually. You can use a more elaborate warm-up script or this one-liner in your deployment pipeline.

curl https://my-page.com/