1

我有一个 Web 应用程序,有时会挂起。我想调查原因,当它挂起时,我需要获取进程的内存转储。

所以我的想法是监控网站,当我检测到挂起时,我想启动一个 .bat 脚本来捕获内存转储,然后运行 ​​IISRESET 以重新启动,以便网站再次开始响应。

我的问题是,adplus 启动另一个进程 (cdb.exe) 并立即返回。我需要等待 cdb.exe 完成,然后才能运行 IISRESET。有没有办法在批处理脚本中做到这一点?或者,我可以在 adplus 命令行上指定它不应该在内存转储被收集之前返回吗?

4

2 回答 2

2

To create the memory dump of your web application, the Microsoft Debug Diagnostic Tools are your best option.

You can create an "IIS Hang" rule, monitoring a specific URL, and creating a memory dump whenever no response is received within a specified number of seconds.

The Debug Diagnostics Tools will not help you with regard to restarting IIS (or your app pool), but in general the built-in Application Pool restart options should be sufficient for that. If you make sure "Enable Pinging" is set for your AppPool (on its Health tab), and you also set the other Health/Recycling parameters appropriately, your app should continue responding no matter what happens.

If not, monitoring the output folder with crash dumps from your "IIS Hang" DebugDiag rule, and restarting IIS whenever new files appear should definitely do the trick...

于 2009-12-27T19:55:12.790 回答
2

关于您问题的第二部分,答案是肯定的:您可以(1)在命令行上指定等待(只要您可以访问和修改它);(2) 在批处理文件中等待进程完成。

以最简单的形式,做

(1) 使用START /WAIT cdb parms而不是仅仅使用cdb parms

(2) 尝试FOR /F "tokens=1,2" %a in ('TASKLIST ^| FIND /I "cdb.exe"') DO @ECHO %a %b将 ECHO 替换为您想要的命令。

于 2009-12-30T07:46:05.393 回答