How do I reset application.cfc without resetting the server instance? [duplicate]

空扰寡人 提交于 2019-12-22 07:45:32

问题


Possible Duplicate:
restart application without restarting server?

How do I reset a Coldfusion Application / application.cfc without resetting the Coldfusion Server instance? If I remember right, there are a few tricks out there such as creating a reinit function within application.cfc or renaming the file.


回答1:


A couple of steps:

First, make sure all your application initialization logic is contained inside the OnApplicationStart method of your CFC. If it has nested calls, that is fine - just so long as you can re-initialize your application easily through a single call makes your life much easier.

Second, this is the code I use in the OnRequestStart method of application.cfc

<cfif structKeyExists(url,'resetappvars')>
  <cfset OnApplicationStart() />
</cfif>

Feel free to use whatever coded value you would like in place of resetAppVars.




回答2:


CF9 Doc:

To restart the application, you can stop the application using ApplicationStop() and the next request to any page in this application automatically starts it.

ApplicationStop() is new in ColdFusion 9.




回答3:


If you're on CF8 and using the "if reinit, then call onApplicationStart()" approach, make sure you avoid race conditions. This is a good explanation: http://blog.bullamakanka.net/2009/12/coldfusion-shared-scopes-and-race.html



来源:https://stackoverflow.com/questions/1902109/how-do-i-reset-application-cfc-without-resetting-the-server-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!