How do I restart an application in ColdFusion?
There are a few answers to this question. ColdFusion will automatically run the onApplicationStart method the first time your application is accessed. You can run the method manually by inserting some code. The following code could be added to your onRequestStart method to allow for a URL variable to re-init the application.
It is important to note though that this will not call the method in a single threaded manner. If that doesn't matter, then this provides a simple solution.
Another way to do this would be to set an application timeout of 0 seconds:
Hit your application one more time and it will restart. You would then want to reset the timeout back to a good value.
However - in both cases, the active sessions will not be reset.
This question was written by Raymond Camden.
It was last updated on September 15, 2006 at 10:26:04 AM EDT.
CFML Referenced
Categories
Comments
Comment made by Tom Chiverton on September 15, 2006 at 10:53 AM
You can make the first suggestion single thread using a name exclusive cflock: <cfif structKeyExists(url, "reinit")> <cflock name="reinit_app" > <cfset onApplicationStart()> </cflock> </cfif>
You probably want to have some secret too to stop anyone from doing it (if it takes a while, this is a good DoS: <cfif structKeyExists(url, "reinit") and url.reinit eq 'w53c9bv'>
Comment made by Raymond Camden on September 15, 2006 at 11:04 AM
Good points Tom. Thanks.