I'm struggling to get my IIS site to autostart. I'm using Quartz.Net inside it for nightly tasks but they aren't running because IIS disposes of it before they can run. I've attempted to set it to autostart and stay runninig by doing the following (using these instructions ):
ApplicationHost.Config:
<configuration>
<configSections>
...
<system.applicationHost>
<applicationPools>
<add name="DefaultAppPool" enable32BitAppOnWin64="true" managedRuntimeVersion="v4.0" />
<add name="ASP.NET v4.0" enable32BitAppOnWin64="false" managedRuntimeVersion="v4.0" />
<add name="ASP.NET v4.0 Classic" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" />
<add name="Classic .NET AppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" />
...
<add name="AUTOSTARTSITE" autoStart="true" managedPipelineMode="Integrated" startMode="AlwaysRunning">
<processModel identityType="NetworkService" />
</add>
<applicationPoolDefaults managedRuntimeVersion="v4.0">
<processModel identityType="NetworkService" />
</applicationPoolDefaults>
</applicationPools>
...
<sites>
<site name="AUTOSTARTSITE" id="10" serverAutoStart="true" serviceAutoStartEnabled="true" serviceAutoStartProvider="StartUpCode">
<application path="/" applicationPool="AUTOSTARTSITE">
<virtualDirectory path="/" physicalPath="E:\websites\AUTOSTARTSITE" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:AUTOSTARTSITE.com" />
</bindings>
<traceFailedRequestsLogging enabled="true" />
<logFile directory="%SystemDrive%\inetpub\logs\LogFiles" />
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%SystemDrive%\inetpub\logs\LogFiles" />
<traceFailedRequestsLogging directory="%SystemDrive%\inetpub\logs\FailedReqLogFiles" />
</siteDefaults>
<applicationDefaults applicationPool="DefaultAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
<serviceAutoStartProviders>
<add name="StartUpCode" type="StartUpCode, AUTOSTARTSITE" />
</serviceAutoStartProviders>
<webLimits />
</system.applicationHost>
...
And here is my startup code. I didn't put in a namespace, and I have it log that it runs so I can confirm the process is working. Unfortunatly, it does not run.
StartUpCode:
public class StartUpCode : System.Web.Hosting.IProcessHostPreloadClient
{
readonly log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public void Preload(string[] parameters)
{
SetupJobs();
logger.Info("Quartz Jobs Setup Successfully");
}
}
Despite these changes, it runs the same as before. Am I missing something obvious?
I think for all this stuff to work properly you need to install Application Initialization feature for IIS:
You can find more details on how it is supposed to work here .
We found generally that no matter what sometimes it just does not work. So there are really 2 solutions here:
I would definitely prefer option 1 to not depend on IIS life-cycle for critical scheduling operations. Even though this approach with IIS hosting is still quite popular and we use it there is just too many problems with it in my experience.
We too had same issue using Quartz the reason was the IIS pool was shutting down after some idle time.So we had to prevent it from shutting down and it worked for Us.
Find more details here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.