简体   繁体   English

是否收到IIS重置通知?

[英]Be notified of an IIS Reset?

We have a system with a web app and a bunch of Windows Services doing some background work. 我们有一个带有Web应用程序的系统和一堆Windows服务,它们在做一些后台工作。

Whenever we need to make a more substantial change to the system, we end up having to issue an IIS Reset, and then manually restart all relevant Windows services. 每当我们需要对系统进行实质性更改时,最终都必须发出IIS重置,然后手动重新启动所有相关的Windows服务。

Is there any way at all to be notified of such IISReset events in C# code, so that our Windows Services could restart themselves, whenever they detect such an IISReset command being executed? 是否有任何办法可以用C#代码通知此类IISReset事件,以便我们的Windows服务在检测到正在执行的IISReset命令时可以自行重启?

Thanks! 谢谢! Marc

Couldn't you just write a batch file to call IIS Reset and then restart the Windows Services? 您不能只编写一个批处理文件来调用IIS重置,然后重新启动Windows服务吗?

I think the way to start a Windows Service is: 我认为启动Windows服务的方法是:

NET START "SERVICE NAME"

Agree with Nebakanezer, you may need to stop the service first though. 同意Nebakanezer,不过您可能需要先停止该服务。

  • Option 1 选项1

NET STOP "SERVICE NAME"
NET START "SERVICE NAME"

  • Option 2 选项2

What about deploying a dummy asp.net app to the IIS server, then you can detect the application starting which should only happen on an IISReset and trigger the stop and restart of the services? 将虚拟的asp.net应用程序部署到IIS服务器该如何处理,然后您可以检测到仅在IISReset上发生的应用程序启动并触发服务的停止和重新启动? I'm not sure if IIS has a tightened security model that will allow you to do thinks like stop services or trigger a batch file to do same but it's worth a try. 我不确定IIS是否具有严格的安全模型,该模型将使您能够进行停止服务或触发批处理文件等操作,但是值得尝试。

  • Option 3 选项3

If thats not an option for whatever reason, you could pull something together that monitors the IIS logs, I believe they log IIS resets. 如果由于某种原因这不是一个选择,那么您可以将一些东西组合在一起以监视IIS日志,我相信它们会记录IIS重置。

You could also plug into Windows Instrumentation with you own custom Windows Query Language expression. 您还可以使用自己的自定义Windows查询语言表达式将其插入Windows Instrumentation。 I've never used it for IIS directly, but I expect that there would be objects you can listen to, which lets you be aware of such changes. 我从未将它直接用于IIS,但我希望可以听一些对象,这样您就可以知道这些更改。 You can check this out : http://www.csharphelp.com/archives2/archive334.html as a starting point for research. 您可以查看: http : //www.csharphelp.com/archives2/archive334.html作为研究的起点。

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

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