'遇到抽风自动重启进程池 by zh99998 2010-7-16
'only for IIS7 请用管理员身份运行
'2010-7-18更新,解决缓存问题
'配置部分
AppPool="66RPG" '应用池名称
URL1="http://bbs.66rpg.com/appreset_test.php" '测试接口页面1
URL2="http://bbs.66rpg.com/appreset_test.htm" '测试接口页面2
'因为抽风时只是不能解析php,于是检测到php无法访问时,检测另一个非php页面,若这个页面也不能访问,则不重启进程池
WaitTime=100000 '每次检测的时间间隔,单位毫秒
LogFile="d:\AppPool_reset_log.txt" '日志文件路径
TTL=5 '连续重启上限,这个是为了防止由于某些异常而不断重启进程池
'配置部分结束
Set FSO = CreateObject("Scripting.FileSystemObject")
Set LogFile = FSO.OpenTextFile (LogFile, 8, True)
Set ws = CreateObject("Wscript.shell")
t=TTL
LogFile.WriteLine(now()&" 检测程序启动")
Do
Set http = CreateObject("Microsoft.XMLHTTP")
http.Open "GET",URL1&"?test="&now(),0
http.Send()
if http.responseText <> "1" then
Set http = CreateObject("Microsoft.XMLHTTP")
http.Open "GET",URL2&"?test="&now(),0
http.Send()
if http.responseText = "1" then
if t>0 then
LogFile.WriteLine(now()&" 检测到抽风,尝试重启进程池")
ws.run "%windir%\system32\inetsrv\appcmd.exe stop APPPOOL "&AppPool,0,true
ws.run "%windir%\system32\inetsrv\appcmd.exe start APPPOOL "&AppPool,0,true
t=t-1
else
LogFile.WriteLine(now()&" 重启进程池无效,持续抽风中") '超过连续重启次数上限
end if
else
LogFile.WriteLine(now()&" 接口页面访问失败")
t=TTL
end if
else
'LogFile.WriteLine(now()&" 一切正常") '如果不需要正常记录,可以把这句注释掉
t=TTL
end if
wscript.sleep WaitTime
Loop