Paul Creasey Paul Creasey - 1 year ago 136
ASP.NET (C#) Question

IIS app pool recycle + quartz scheduling

I'm running a web app on IIS 7.5 and it needs to recycle occasionally (otherwise memory usage gets out of handing, something i'm looking into!).

When it recycles, it is effectively not running until another request comes in, which quartz is not going to run.

Is there any way to have IIS automatically bring up 1 work process immediately after recycling the app pool to ensure quartz is always online?

Answer Source

Yes! details it quite nicely, basically you need to:

  1. Edit C:\Windows\System32\inetsrv\config\applicationHost.config to include:

        <add name="MyAppWorkerProcess" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" /> 
  2. Declare what should be run as the "warm-up" for your site

        <site name="MySite" id="1"> 
            <application path="/" serviceAutoStartEnabled="true" serviceAutoStartProvider="PreWarmMyCache" />
        <add name="PreWarmMyCache" type="PreWarmCache, MyAssembly" /> 
  3. Configure your application with whatever "warm-up" logic you would like:

    public class PreWarmCache : System.Web.Hosting.IProcessHostPreloadClient {
        public void Preload(string[] parameters) { 
            // Perform initialization and cache loading logic here... 

Note: If all you need is for the w3wp.exe process to be present I believe only step 1 is necessary. If you also need other items (like certain things to be loaded into memory) then step 2 and 3 would also be used.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download