coldfusioncoldfusion-8coldfusion-9coldfusion-6coldfusion-7

How to restart Coldfusion Application Server when application times out?


Is there any way to restart the CF server through the Application.cfc, when the application times out? As per Adobe documentation, they showed as follows:

<cffunction name="onApplicationEnd">
    <cfargument name="ApplicationScope" required=true/>
    <cflog file="#This.Name#" type="Information" 
        text="Application #Arguments.ApplicationScope.applicationname# Ended" >
</cffunction>

What I would like to do is replace the <cflog> above with <cfexecute> as follows:

<cfexecute name = "C:\CFRestart.bat"
    outputFile = "C:\output.txt"
    timeout = "1">
</cfexecute>

So OnApplicationEnd will run the CFRestart.bat file when the application times out. Is this possible or not?


Solution

  • onApplicationEnd is not likely to be reached unless you have a very quiet application because every time someone access the application the timeout is reset.

    I'd be very uncomfortable using an application to restart a coldfusion instance. I can see all sorts of horrible security issues etc looming. To be honest I'm not really sure why you'd want to restart the server if your application end.

    Also, according to the docs onApplicationEnd is called when the server is restarted, so if you did get this working, when you restart your server the application would also have a go at restarting your server. This would get very messy.