简体   繁体   English

IIS7重新启动问题

[英]IIS7 restart issue

I have a webservice on one of my websites which restarts the websites app pool. 我在一个网站上有一个Web服务,可重新启动网站应用程序池。

The problem Im getting is the IIS7 app pool keeps stopping with the following warning and then error: 我得到的问题是IIS7应用程序池不断停止,并显示以下警告,然后出现错误:

Warning: A process serving application pool 'appPoolNameHere' exceeded time limits during shut down. 警告:在关闭期间,为应用程序池'appPoolNameHere'提供服务的进程超过了时间限制。

Error: Application pool 'appPoolNameHere' is being automatically disabled due to a series of failures in the process(es) serving that application pool. 错误:由于为该应用程序池提供服务的进程中的一系列失败,因此自动禁用了应用程序池“ appPoolNameHere”。

The code I am using to do this is: 我用于执行此操作的代码是:

            try
        {

            var serverManager = new ServerManager();

            var currentPoolName = SettingsManager.AppPoolName;

            if (!string.IsNullOrEmpty(currentPoolName))
                serverManager.ApplicationPools[currentPoolName].Recycle();

            HttpRuntime.Close();
        }
        catch (Exception ex)
        {                
            var exceptionManager = ExceptionManagerFactory.GetExceptionManager();
            exceptionManager.LogException(ExceptionManager.Severities.Critical, ex,
                                          "App Pool restart failed");
        }

I am not getting any exceptions being thrown here, but the app pool is stopping, this doesnt happen all the time and is very hard to replicate, I have tried several different things even just hitting the hell out of that service and sometimes its fine other times it dies. 我没有在这里引发任何异常,但是应用程序池正在停止,这种情况不会一直发生并且很难复制,我尝试了几种不同的方法,甚至只是从该服务中解脱出来,有时还可以死了

Is there anything I can do to fix this? 有什么我可以解决的吗?

The reason I have to restart it is due to an external config file to the webconfig which deals with the url redirects which is updated from the admin system. 我必须重新启动它的原因是由于webconfig的外部配置文件处理了从管理系统更新的URL重定向。

Thanks for any help with this. 感谢您对此的任何帮助。

Well I seem to have sorted (not fixed) the issue, with some tape and sticky-back-plastic. 好吧,我似乎已经用一些胶带和粘性塑料对问题进行了分类(未解决)。

The solution 解决方案

Changed app pool setting: Rapid-Fail Protection to false 更改了应用程序池设置:“ 快速失败保护”设置为“ false”

This stops IIS from killing the app pool after several failed requests to it. 这将阻止IIS在几次失败的请求之后终止应用程序池。

I also added in retry system, so if the recycle request fails it waits for 10secs and tries again, it will do this 5 times before giving up and sending out an exception notice. 我还添加了重试系统,因此,如果回收请求失败,它将等待10秒,然后再次尝试,它将执行5次此操作,然后放弃并发出异常通知。

This has fixed the problem, and everything seems to be working well again, although something about this screams this is wrong!! 这已经解决了问题,并且一切似乎都再次正常运行,尽管与此有关的某些尖叫声表明这是错误的! at me. 对我。

Only if IIS would monitor other files in a website and restart the app pool when it saw a change. 仅当IIS会监视网站中的其他文件并在看到更改时重新启动应用程序池时,才可以。

I didn't work with Microsoft.Web.Administration namespace, but what about unloading application domain and sending request to your website so that to start application again? 我没有使用Microsoft.Web.Administration命名空间,但是如何卸载应用程序域并将请求发送到您的网站以便再次启动应用程序呢?

Good example (2nd point) by Peter Bromberg how to do this. 彼得·布隆伯格(Peter Bromberg)的一个很好的例子 (第二点)。

Update. 更新。

Reading error stack 读取错误堆栈

System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at Microsoft.Web.Administration.Interop.IAppHostMethodInstance.Execute()

I thought of most common reason: insufficient rights. 我想到了最常见的原因:权利不足。 All administrative actions require administrative rights. 所有管理措施都需要管理权限。 When code above is executed, which user account is impersonated? 执行以上代码后,将模拟哪个用户帐户? IUSR? IUSR? Switch to any admin for that block and it should work without exception. 切换到该块的任何管理员,它应该正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM