Skip to content

Instantly share code, notes, and snippets.

@adamcameron
Created July 28, 2012 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamcameron/3193092 to your computer and use it in GitHub Desktop.
Save adamcameron/3193092 to your computer and use it in GitHub Desktop.
Investigation into applicationStop(): http://bit.ly/OlLnTM
// Application.cfc
component {
this.name = "testApplicationStop";
this.applicationTimeout = createTimeSpan(0, 0, 1, 0);
function onApplicationStart(){
application.key = createUuid();
application.startedAt = timeFormat(now(), "HH:MM:SS.LLL") & "<br />";
application.firstVar = "First var using #application.startedAt#";
application.secondVar = "Second using #application.startedAt#";
param name="server.requestCount" default=0;
}
function onRequestStart(){
request.requestId = ++server.requestCount;
request.appKey = application.key;
writeLog(file=this.name, text="Request #request.requestId# of #listLast(getBaseTemplatePath(), "\")# started at #formattedNow()# for application key: #application.key# (#request.appKey#)");
}
function onRequestEnd(){
writeLog(file=this.name, text="Request #request.requestId# of #listLast(getBaseTemplatePath(), "\")# ended at #formattedNow()# for application key: #application.key# (#request.appKey#)");
}
function formattedNow(){
return timeFormat(now(), "HH:MM:SS.LLL");
}
}
<!--- long.cfm --->
<cfflush interval="1">
<cfoutput>
#application.firstVar#<br />
<!---emulate a long-running request --->
<cfset sleep(10000)>
#application.secondVar#<br />
</cfoutput>
<!--- other.cfm --->
<cfflush interval="1">
<cfoutput>
#application.firstVar#<br />
#application.secondVar#<br />
</cfoutput>
<!--- start.cfm --->
<cfdump var="#application#" label="Started">
<!--- stop.cfm --->
<cfset applicationStop()>
<cfdump var="#application#" label="Stopped">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment