当后台线程正在运行时,我开始在 Appharbor 上托管的 .Net MVC 网络应用程序中看到错误 - 经过仔分割析 - 我无法找出原因。
首先,我注意到的异常是 ThreadAbortException
。
然而,这实际上只是表示线程正在被杀死。在线程被杀死之前,您可以看到 IIS 创建了一个新的 worker,并在同一台机器上调用了 Application_Start
。新应用程序启动并运行后,IIS 会终止旧应用程序并按预期处理新请求。
同时,IIS 记录一条消息:
ShutDown Message: IIS configuration change
HostingEnvironment initiated shutdown
HostingEnvironment caused shutdown
ShutDown Stack: at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at System.Web.Hosting.HostingEnvironment.InitiateShutdownInternal()
at System.Web.Hosting.HostingEnvironment.InitiateShutdownWithoutDemand()
at System.Web.Hosting.PipelineRuntime.StopProcessing()
在 .Net Health Monitor Logging 中,您会得到:
Message: Application is shutting down. Reason: Configuration changed.
Event Detail Code: 50004
快速谷歌显示源代码我怀疑是错误的原因:
if (!HostingEnvironment.StopListeningWasCalled && !HostingEnvironment.ShutdownInitiated) {
// If GL_STOP_LISTENING wasn't triggered, the reset is likely due to a configuration change.
HttpRuntime.SetShutdownReason(ApplicationShutdownReason.ConfigurationChange, "IIS configuration change");
}
来源:https://github.com/Microsoft/referencesource/blob/master/System.Web/Hosting/IPipelineRuntime.cs
我的第一个想法是检查 bin 文件夹和主应用程序目录中文件更改的时间戳 - 然而,在没有任何文件更改的情况下抛出此错误。鉴于它只发生在 Appharbor 上,我无法附加到进程并以这种方式进行调试。我还监控了内存使用情况,没有发现任何问题。
源代码指出:
If GL_STOP_LISTENING wasn't triggered, the reset is likely due to a configuration change.
因此,如果 web.config/其他配置文件未更改,什么其他可能导致错误和应用程序回收?
最佳答案
原因有很多,列在这个helpful blog entry .
- 应用程序池设置
- machine.config 的 processModel 元素
- 内存限制
- 请求限制
- 超时
关于c# - IIS 抛出 ThreadAbortException 并回收 worker,IIS 日志记录为 "IIS configuration change"的可能原因是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29496331/