[英]IIS Website not autostarting
I'm struggling to get my IIS site to autostart. 我正在努力使我的IIS站点能够自动启动。 I'm using Quartz.Net inside it for nightly tasks but they aren't running because IIS disposes of it before they can run.
我在其中使用Quartz.Net来执行夜间任务,但它们没有运行,因为IIS在运行它们之前就将其处理掉。 I've attempted to set it to autostart and stay runninig by doing the following (using these instructions ):
我尝试通过执行以下操作(使用这些说明 )将其设置为自动启动并保持运行状态:
ApplicationHost.Config: 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: 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: 我认为要使所有这些东西正常工作,您需要为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. 我绝对希望选项1不依赖IIS生命周期进行关键的调度操作。 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.
尽管这种使用IIS托管的方法仍然非常流行,并且我们使用它,但根据我的经验,仍然存在太多问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.