如何防止 ASP.Net 站点被 IIS 卸载?
我有一个可能是世界上最愚蠢的网站 - 它每小时醒来一次并将时间戳写入日志文件。当应用程序启动时,它会在日志中显示时间戳,当应用程序终止时,也会发生同样的情况。
在 IIS 中,我进入其应用程序池并将空闲超时设置为 0,然后设置生成回收事件日志条目 >常规时间间隔为 False。
然而,该网站仍然每天大约自行卸载一次 - 我在日志中收到“应用程序正在卸载...”条目,并且它一直处于死状态,直到我下次访问它。
如何防止它卸载?
(显然,一旦我解决了这个问题,这个网站就会做更多的事情——现在隔离问题是尽可能简单的。)
How do I prevent an ASP.Net site from being unloaded by IIS?
I have what may be the dumbest website in the world - once per hour it wakes up and writes a timestamp to a log file. When the app starts, it says so with a timestamp in the log, and when it dies, same thing.
In IIS I went into its Application Pool and set the Idle Timeout to 0 and set Generate Recycle Event Log Entry > Regular Time Interval to False.
Yet the site still unloads itself about once per day - I get the App Unloading... entry in the log and it sits dead until I next visit it.
How do I prevent it from unloading?
(Obviously this site will do more once I get this resolved - for now it's as simple as possible to isolate the problem.)
发布评论
评论(2)
应用程序池还有另一个属性,使其每 N 分钟(默认为 1740,或每 29 小时)自动回收一次。将其设置为零以禁用回收。该属性(在 IIS7 上)位于“回收”标题下,称为“常规时间间隔(分钟)”
The application pool has another property that causes it to be automatically recycled every N minutes (defaults to 1740, or every 29 hours.) Make this zero to disable recycling. The property is (on IIS7) under the "Recycling" heading and is called "Regular Time Interval (minutes)"
除了 @jlew 的建议之外,如果您在 ASP.Net 中连续/定期运行后台任务/计时器,而没有 Windows 服务和计划任务的安装/配置/维护负担,那么本文中的指南也很重要:
http://haacked .com/archive/2011/10/16/the-dangers-of-implementing-recurring-background-tasks-in-asp-net.aspx
它包括一个有用的帮助程序库 WebBackgrounder,它抽象了以下建议:这篇文章处理正常关闭和后台任务的一些典型需求。
它不会为您配置 IIS - 您需要自己修改回收设置。
In addition to @jlew's recommendation, the guidance in this article is important if you're running a background task/timer continuously/periodically in ASP.Net without the install/configuration/maintenance burden of Windows Services and Scheduled Tasks:
http://haacked.com/archive/2011/10/16/the-dangers-of-implementing-recurring-background-tasks-in-asp-net.aspx
It includes a useful helper library, WebBackgrounder, which abstracts the advice in the article to handle graceful shutdown and some of the typical wants/needs of a background task.
It does not configure IIS for you - you'll need to modify the recycling settings yourself.