Re: onApplicationStart and cfmail, when doess server start?
yeah, i thought it would be some thing every one but me has done. a simple email to alert you that the server has started. we have diff monitering in place, but i cant touch it. thanks a bunch. -m On Tue, Apr 1, 2014 at 2:00 PM, Bobby bo...@acoderslife.com wrote: The next thing that comes to mind is to parse the CF server.log file for the instance you are targeting. There are log entries for stopping and starting in there. ButŠI¹m guessing you are wanting this to be used as an alert not post-portem investigation. There are plenty of infrastructure monitoring applications and 3rd party services out there for monitoring your production servers (including the services). My company uses PRTG for performance/service monitoring (http://www.paessler.com/prtg) to cover all of our different servers. Im mostly responsible for the health of our CF servers though and FusionReactor works great for me. If you set it up correctly, it can notify you of service availability changes. None of the above actual means that a server was ³rebooted² though and a CF service stopping/starting also doesn¹t mean that someone manually triggered it. Also, keep in mind that something running ON the server that is supposed to send you this email is probably not going to work if its running on the service you are trying to monitor. On 4/1/14, 12:11 PM, morchella morchella.delici...@gmail.com wrote: looks like onServerStart is turned off. i cant change that on our server. On Tue, Apr 1, 2014 at 11:49 AM, morchella morchella.delici...@gmail.comwrote: thanks guys! i was unfamilar with onServerStart. looking now! Much appreciated! On Tue, Apr 1, 2014 at 11:44 AM, Bobby bo...@acoderslife.com wrote: The behavior you explained is expected. onApplicationStart() isnšt triggered until the first request to the application. Check out onServerStart and Server.cfc http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WS7AC9408A-1AC6-4ab7- 9C8 E-CF1DA8FCA16D.html http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/W S7AC9408A-1AC6-4ab7-9C8E-CF1DA8FCA16D.html On 4/1/14, 11:31 AM, morchella morchella.delici...@gmail.com wrote: so i am trying some thing out on localhost befor i move to dev i want to know when my cf server was started or restarted. so after my onApplicationStart i put in a cfmail and fir up an instance of cf9 for my localhost. i dont get the email unless i actually goto 127.x.x.x to view a page. i thought i should get it imeditaly when the server starts? how would or should i be doing this. thanks a bunch. will help to know when offshore reboots some thing with out informing us. -m ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358284 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: onApplicationStart and cfmail, when doess server start?
ApplicationStart does not fire until the Application is hit. You're looking for onServerStart. On Tue, Apr 1, 2014 at 11:31 AM, morchella morchella.delici...@gmail.comwrote: so i am trying some thing out on localhost befor i move to dev i want to know when my cf server was started or restarted. so after my onApplicationStart i put in a cfmail and fir up an instance of cf9 for my localhost. i dont get the email unless i actually goto 127.x.x.x to view a page. i thought i should get it imeditaly when the server starts? how would or should i be doing this. thanks a bunch. will help to know when offshore reboots some thing with out informing us. -m ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358271 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: onApplicationStart and cfmail, when doess server start?
That is correct behavior. An application does not start until a page within its scope is requested. You have a few options though. Use onServerStart (CF 9+). Use another server to monitor it. Use a third party program such as FusionReactor. I highly recommend it and it's well worth the money spent. On Tue, Apr 1, 2014 at 10:31 AM, morchella morchella.delici...@gmail.comwrote: so i am trying some thing out on localhost befor i move to dev i want to know when my cf server was started or restarted. so after my onApplicationStart i put in a cfmail and fir up an instance of cf9 for my localhost. i dont get the email unless i actually goto 127.x.x.x to view a page. i thought i should get it imeditaly when the server starts? how would or should i be doing this. thanks a bunch. will help to know when offshore reboots some thing with out informing us. -m ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358272 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: onApplicationStart and cfmail, when doess server start?
The behavior you explained is expected. onApplicationStart() isn¹t triggered until the first request to the application. Check out onServerStart and Server.cfc http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WS7AC9408A-1AC6-4ab7-9C8 E-CF1DA8FCA16D.html On 4/1/14, 11:31 AM, morchella morchella.delici...@gmail.com wrote: so i am trying some thing out on localhost befor i move to dev i want to know when my cf server was started or restarted. so after my onApplicationStart i put in a cfmail and fir up an instance of cf9 for my localhost. i dont get the email unless i actually goto 127.x.x.x to view a page. i thought i should get it imeditaly when the server starts? how would or should i be doing this. thanks a bunch. will help to know when offshore reboots some thing with out informing us. -m ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358273 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: onApplicationStart and cfmail, when doess server start?
thanks guys! i was unfamilar with onServerStart. looking now! Much appreciated! On Tue, Apr 1, 2014 at 11:44 AM, Bobby bo...@acoderslife.com wrote: The behavior you explained is expected. onApplicationStart() isnšt triggered until the first request to the application. Check out onServerStart and Server.cfc http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WS7AC9408A-1AC6-4ab7-9C8 E-CF1DA8FCA16D.html On 4/1/14, 11:31 AM, morchella morchella.delici...@gmail.com wrote: so i am trying some thing out on localhost befor i move to dev i want to know when my cf server was started or restarted. so after my onApplicationStart i put in a cfmail and fir up an instance of cf9 for my localhost. i dont get the email unless i actually goto 127.x.x.x to view a page. i thought i should get it imeditaly when the server starts? how would or should i be doing this. thanks a bunch. will help to know when offshore reboots some thing with out informing us. -m ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358274 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: onApplicationStart and cfmail, when doess server start?
looks like onServerStart is turned off. i cant change that on our server. On Tue, Apr 1, 2014 at 11:49 AM, morchella morchella.delici...@gmail.comwrote: thanks guys! i was unfamilar with onServerStart. looking now! Much appreciated! On Tue, Apr 1, 2014 at 11:44 AM, Bobby bo...@acoderslife.com wrote: The behavior you explained is expected. onApplicationStart() isnšt triggered until the first request to the application. Check out onServerStart and Server.cfc http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WS7AC9408A-1AC6-4ab7-9C8 E-CF1DA8FCA16D.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WS7AC9408A-1AC6-4ab7-9C8E-CF1DA8FCA16D.html On 4/1/14, 11:31 AM, morchella morchella.delici...@gmail.com wrote: so i am trying some thing out on localhost befor i move to dev i want to know when my cf server was started or restarted. so after my onApplicationStart i put in a cfmail and fir up an instance of cf9 for my localhost. i dont get the email unless i actually goto 127.x.x.x to view a page. i thought i should get it imeditaly when the server starts? how would or should i be doing this. thanks a bunch. will help to know when offshore reboots some thing with out informing us. -m ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358275 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: onApplicationStart and cfmail, when doess server start?
The next thing that comes to mind is to parse the CF server.log file for the instance you are targeting. There are log entries for stopping and starting in there. But I¹m guessing you are wanting this to be used as an alert not post-portem investigation. There are plenty of infrastructure monitoring applications and 3rd party services out there for monitoring your production servers (including the services). My company uses PRTG for performance/service monitoring (http://www.paessler.com/prtg) to cover all of our different servers. Im mostly responsible for the health of our CF servers though and FusionReactor works great for me. If you set it up correctly, it can notify you of service availability changes. None of the above actual means that a server was ³rebooted² though and a CF service stopping/starting also doesn¹t mean that someone manually triggered it. Also, keep in mind that something running ON the server that is supposed to send you this email is probably not going to work if its running on the service you are trying to monitor. On 4/1/14, 12:11 PM, morchella morchella.delici...@gmail.com wrote: looks like onServerStart is turned off. i cant change that on our server. On Tue, Apr 1, 2014 at 11:49 AM, morchella morchella.delici...@gmail.comwrote: thanks guys! i was unfamilar with onServerStart. looking now! Much appreciated! On Tue, Apr 1, 2014 at 11:44 AM, Bobby bo...@acoderslife.com wrote: The behavior you explained is expected. onApplicationStart() isnšt triggered until the first request to the application. Check out onServerStart and Server.cfc http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WS7AC9408A-1AC6-4ab7- 9C8 E-CF1DA8FCA16D.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/W S7AC9408A-1AC6-4ab7-9C8E-CF1DA8FCA16D.html On 4/1/14, 11:31 AM, morchella morchella.delici...@gmail.com wrote: so i am trying some thing out on localhost befor i move to dev i want to know when my cf server was started or restarted. so after my onApplicationStart i put in a cfmail and fir up an instance of cf9 for my localhost. i dont get the email unless i actually goto 127.x.x.x to view a page. i thought i should get it imeditaly when the server starts? how would or should i be doing this. thanks a bunch. will help to know when offshore reboots some thing with out informing us. -m ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358277 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: onApplicationStart
This doesnt work for me and I cannot work out why? I run onApplicationStart in application.cfc and all my old application variables still exist, i have to restart the service all the time but i can't do this on my shared server. What is another way besides creating a temp file to explicitly reset those variables? Is there a way to make the Application expire and restart (sort of speak)? Here's what I use: cffunction name=onRequestStart returntype=void output=false cfif structKeyExists(url,reinitApp) cflock scope=application type=exclusive timeout=5 throwontimeout=true cfset onApplicationStart() /cflock /cfif /cffunction Then add ?reinitApp=1 in any url to restart the app Will ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:335994 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: onApplicationStart
That's by design. CF knows when an application starts. You can 'force' it a few ways. 1) In CF9, within onRequestStart, add a check for url.init (or some such), and run applicationStop(), you then need to reload the current request. 2) Or even simpler, within onRequestStart, add a check for a url var and simply do onApplicationStart(); This will NOT single thread the call, but if you are just setting up a bunch of variables, you most likely do not need to be concerned. 3) I don't really recommend this, but you can also just rename the application. On Wed, Aug 4, 2010 at 2:56 PM, Matt Coldfusion i...@fusionserve.net wrote: This doesnt work for me and I cannot work out why? I run onApplicationStart in application.cfc and all my old application variables still exist, i have to restart the service all the time but i can't do this on my shared server. What is another way besides creating a temp file to explicitly reset those variables? Is there a way to make the Application expire and restart (sort of speak)? Here's what I use: cffunction name=onRequestStart returntype=void output=false cfif structKeyExists(url,reinitApp) cflock scope=application type=exclusive timeout=5 throwontimeout=true cfset onApplicationStart() /cflock /cfif /cffunction Then add ?reinitApp=1 in any url to restart the app Will ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:335996 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: onApplicationStart
Here's the poor mans answer to applicationStop(), it works on CF7 CF8. |||cfset| |application.setIsInited(false) / | See Mister Dai for a more detailed explanation: http://misterdai.wordpress.com/2010/06/11/cf-flag-application-to-run-onapplicationstart/ | | Thanks, Eric Cobb ECAR Technologies, LLC http://www.ecartech.com http://www.cfgears.com Raymond Camden wrote: That's by design. CF knows when an application starts. You can 'force' it a few ways. 1) In CF9, within onRequestStart, add a check for url.init (or some such), and run applicationStop(), you then need to reload the current request. 2) Or even simpler, within onRequestStart, add a check for a url var and simply do onApplicationStart(); This will NOT single thread the call, but if you are just setting up a bunch of variables, you most likely do not need to be concerned. 3) I don't really recommend this, but you can also just rename the application. On Wed, Aug 4, 2010 at 2:56 PM, Matt Coldfusion i...@fusionserve.net wrote: This doesnt work for me and I cannot work out why? I run onApplicationStart in application.cfc and all my old application variables still exist, i have to restart the service all the time but i can't do this on my shared server. What is another way besides creating a temp file to explicitly reset those variables? Is there a way to make the Application expire and restart (sort of speak)? Here's what I use: cffunction name=onRequestStart returntype=void output=false cfif structKeyExists(url,reinitApp) cflock scope=application type=exclusive timeout=5 throwontimeout=true cfset onApplicationStart() /cflock /cfif /cffunction Then add ?reinitApp=1 in any url to restart the app Will ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:335997 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: onApplicationStart
Huh, not sure what happened with the formatting on that. Here you go: cfset application.setIsInited(false) / Thanks, Eric Cobb ECAR Technologies, LLC http://www.ecartech.com http://www.cfgears.com Eric Cobb wrote: Here's the poor mans answer to applicationStop(), it works on CF7 CF8. |||cfset| |application.setIsInited(false) / | See Mister Dai for a more detailed explanation: http://misterdai.wordpress.com/2010/06/11/cf-flag-application-to-run-onapplicationstart/ | | Thanks, Eric Cobb ECAR Technologies, LLC http://www.ecartech.com http://www.cfgears.com Raymond Camden wrote: That's by design. CF knows when an application starts. You can 'force' it a few ways. 1) In CF9, within onRequestStart, add a check for url.init (or some such), and run applicationStop(), you then need to reload the current request. 2) Or even simpler, within onRequestStart, add a check for a url var and simply do onApplicationStart(); This will NOT single thread the call, but if you are just setting up a bunch of variables, you most likely do not need to be concerned. 3) I don't really recommend this, but you can also just rename the application. On Wed, Aug 4, 2010 at 2:56 PM, Matt Coldfusion i...@fusionserve.net wrote: This doesnt work for me and I cannot work out why? I run onApplicationStart in application.cfc and all my old application variables still exist, i have to restart the service all the time but i can't do this on my shared server. What is another way besides creating a temp file to explicitly reset those variables? Is there a way to make the Application expire and restart (sort of speak)? Here's what I use: cffunction name=onRequestStart returntype=void output=false cfif structKeyExists(url,reinitApp) cflock scope=application type=exclusive timeout=5 throwontimeout=true cfset onApplicationStart() /cflock /cfif /cffunction Then add ?reinitApp=1 in any url to restart the app Will ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:335999 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: onApplicationStart
Something a bit simpler may be to use the ApplicationStop function. From QuickDocs: http://cfquickdocs.com/cf9/?getDoc=applicationstopDescription Stops or resets the current application. The application is restarted on the next request to the application. As a caveat, its CF9 only so far. hth, larry You can have a cfif looking for a url variable such as reset. Inside the CFIF you can recall the onapplicationstart method cfif structkeyexists(url, 'reset') cfset onapplicationstart() /cfif Personally, I'd go for a separate reset page. Why have a CFIF if it will rarely, if ever used. On Jan 3, 2008 3:01 PM, Adkins, Randy randy_adk...@sra.com wrote: ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336012 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: onApplicationStart Vs onRequestStart
I am new to ColdFusion and I am having trouble understanding what is the Difference between onApplicationStart method and onRequestStart method other than the Scope. For Example what does it mean by Application? First time a onapplicationstart() runs when the first cfm or cfc is executed in your application. onrequeststart() runs every page request. Yes, you can set application-wide variables in onapplicationstart(). cfset application.dsn = someDSN' You can use that variable throughout your application, on all pages. index.cfm should be able to use: cfoutput#application.dsn#/cfoutput Remember, you MUST prefix the scope to the variable name when it comes to application variables. Same goes for session variables and some others. Whenever you're in doubt, dump the whole application scope on a page, like so: cfdump var=#application# Check it out and see what's there. Will ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313191 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: onApplicationStart Vs onRequestStart
OnApplicationStart runs the first time ANY user hits your site. It's commonly used for setting application variables that rarely change. Things like datasources are a good place for that or initializing a ton of cfobjects. I commonly put a cfif statement in my onRequest event to reset the application variables. like this: cffunction name=OnRequest cfif isDefined(attributes.resetVars) cfset onApplicationStart()/ /cfif /cffunction That way if you can rerun the function from any request. Steve On Sun, Sep 28, 2008 at 8:57 PM, Sherif Abdou [EMAIL PROTECTED]wrote: I am new to ColdFusion and I am having trouble understanding what is the Difference between onApplicationStart method and onRequestStart method other than the Scope. For Example what does it mean by Application? First time a user comes to your site? Does it only run once? I tried to set a Variable in the onApplicationStart method like cfset APPLICATION.ds=myDataSource/ and I get an Error when I say use it in index.cfm. Am i allowed to use this outside in other files Or anything that gets set in onApplicationStart gets passed to onApplicationEnd and thats where the variable get used? Thanks. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313192 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: onApplicationStart Vs onRequestStart
I am new to ColdFusion and I am having trouble understanding what is the Difference between onApplicationStart method and onRequestStart method other than the Scope. For Example what does it mean by Application? First time a user comes to your site? Does it only run once? I tried to set a Variable in the onApplicationStart method like cfset APPLICATION.ds=myDataSource/ and I get an Error when I say use it in index.cfm. Am i allowed to use this outside in other files Or anything that gets set in onApplicationStart gets passed to onApplicationEnd and thats where the variable get used? Thanks. Hi Sherif, Welcome to the community. :) The onApplicationStart and onRequest start events are simply events which occur at a given time and aren't actually tied to any variable scopes, other than the fact that onApplicationStart executes immediately after the application scope is created. But you can do whatever you want to in that method. For example, you can create request variables in the onApplicationStart method, even though it executes before onRequestStart. So the lifespan of an application looks like this: 1. onApplicationStart 2. onSessionStart 3. onRequestStart 4. index.cfm 5. onRequestEnd 6. return to 3 (onRequestStart) and repeat 7. onSessionEnd - user timed out 8. return to 2 (onSessionStart) and repeat for other users 9. onApplicationEnd - application timed out 10. return to 1 (onApplicationStart) the next time the site is visited You can use application variables in index.cfm -- they need to be properly scoped, but if you set them in the onApplicationStart method they should be available. Your onApplicationStart method may not be executing if you haven't specified a name for your application. So your Application.cfc should look similar to this: cfcomponent cfset this.name = myapplication / cffunction name=onApplicationStart access=public cfset application.ds = myDataSource / /cffunction /cfcomponent You can also look to see what variables you have in your application scope from your index.cfm template by dumping the structure like this: cfdump var=#application# / hth -- s. isaac dealey ^ new epoch isn't it time for a change? ph: 781.769.0723 http://onTap.riaforge.org/blog ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313193 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: onApplicationStart Vs onRequestStart
Oh Ok I found what the problem is, I guess my Varaibles in the onApplicationStart got cached, so when I sent it once, launched and then I added another Variables after launched again the application variables dont' get updated. Now How would i prevent it from getting cached? -- Sherif Abdou http://VadexFX.com http://Sherifabdou.com - Original Message - From: s. isaac dealey [EMAIL PROTECTED] To: cf-talk cf-talk@houseoffusion.com Sent: Sunday, September 28, 2008 8:42 PM Subject: Re: onApplicationStart Vs onRequestStart I am new to ColdFusion and I am having trouble understanding what is the Difference between onApplicationStart method and onRequestStart method other than the Scope. For Example what does it mean by Application? First time a user comes to your site? Does it only run once? I tried to set a Variable in the onApplicationStart method like cfset APPLICATION.ds=myDataSource/ and I get an Error when I say use it in index.cfm. Am i allowed to use this outside in other files Or anything that gets set in onApplicationStart gets passed to onApplicationEnd and thats where the variable get used? Thanks. Hi Sherif, Welcome to the community. :) The onApplicationStart and onRequest start events are simply events which occur at a given time and aren't actually tied to any variable scopes, other than the fact that onApplicationStart executes immediately after the application scope is created. But you can do whatever you want to in that method. For example, you can create request variables in the onApplicationStart method, even though it executes before onRequestStart. So the lifespan of an application looks like this: 1. onApplicationStart 2. onSessionStart 3. onRequestStart 4. index.cfm 5. onRequestEnd 6. return to 3 (onRequestStart) and repeat 7. onSessionEnd - user timed out 8. return to 2 (onSessionStart) and repeat for other users 9. onApplicationEnd - application timed out 10. return to 1 (onApplicationStart) the next time the site is visited You can use application variables in index.cfm -- they need to be properly scoped, but if you set them in the onApplicationStart method they should be available. Your onApplicationStart method may not be executing if you haven't specified a name for your application. So your Application.cfc should look similar to this: cfcomponent cfset this.name = myapplication / cffunction name=onApplicationStart access=public cfset application.ds = myDataSource / /cffunction /cfcomponent You can also look to see what variables you have in your application scope from your index.cfm template by dumping the structure like this: cfdump var=#application# / hth -- s. isaac dealey ^ new epoch isn't it time for a change? ph: 781.769.0723 http://onTap.riaforge.org/blog ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313195 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: onApplicationStart Vs onRequestStart
The whole point of putting variables into the application scope is to cache them so you don't have to set them on every request. The reason your variables didn't get set after you added new ones was that your application had already started; OnApplicationStart doesn't run on every request. mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ 2008/9/29 Sherif Abdou Oh Ok I found what the problem is, I guess my Varaibles in the onApplicationStart got cached, so when I sent it once, launched and then I added another Variables after launched again the application variables dont' get updated. Now How would i prevent it from getting cached? -- ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313196 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: onApplicationStart
You can just call onApplicationStart() again, but be aware that it won't be thread safe as it is when the application starts up. On Jan 3, 2008 3:01 PM, Adkins, Randy [EMAIL PROTECTED] wrote: Question: When using the onApplicationStart within an Application.cfc, lets say I wanted to restart the Application to pickup some changes. Now I know you can cycle the CF Services but I do not have that access to the server. What is another way besides creating a temp file to explicitly reset those variables? Is there a way to make the Application expire and restart (sort of speak)? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295782 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: onApplicationStart
You can have a cfif looking for a url variable such as reset. Inside the CFIF you can recall the onapplicationstart method cfif structkeyexists(url, 'reset') cfset onapplicationstart() /cfif Personally, I'd go for a separate reset page. Why have a CFIF if it will rarely, if ever used. On Jan 3, 2008 3:01 PM, Adkins, Randy [EMAIL PROTECTED] wrote: Question: When using the onApplicationStart within an Application.cfc, lets say I wanted to restart the Application to pickup some changes. Now I know you can cycle the CF Services but I do not have that access to the server. What is another way besides creating a temp file to explicitly reset those variables? Is there a way to make the Application expire and restart (sort of speak)? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295786 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: onApplicationStart
What is another way besides creating a temp file to explicitly reset those variables? Is there a way to make the Application expire and restart (sort of speak)? Here's what I use: cffunction name=onRequestStart returntype=void output=false cfif structKeyExists(url,reinitApp) cflock scope=application type=exclusive timeout=5 throwontimeout=true cfset onApplicationStart() /cflock /cfif /cffunction Then add ?reinitApp=1 in any url to restart the app Will ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295784 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: onApplicationStart
No, not really. I put all my initialization logic in a separate method of Application.cfc, and then invoke that method from onRequestStart if certain conditions are met (usually the presence of a reloadApplication URL param that is set to a specific value). Note that this doesn't expire the application, it just reinitializes it. So any pre-existing application variables will continue to exist unless your initialization explicitly overwrites or deletes them. cheers, barneyb On Jan 3, 2008 12:01 PM, Adkins, Randy [EMAIL PROTECTED] wrote: Question: When using the onApplicationStart within an Application.cfc, lets say I wanted to restart the Application to pickup some changes. Now I know you can cycle the CF Services but I do not have that access to the server. What is another way besides creating a temp file to explicitly reset those variables? Is there a way to make the Application expire and restart (sort of speak)? -- Barney Boisvert [EMAIL PROTECTED] http://www.barneyb.com/ Got Gmail? I have 100 invites. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295783 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: onApplicationStart
Sweet.. thanks -Original Message- From: Will Tomlinson [mailto:[EMAIL PROTECTED] Sent: Thursday, January 03, 2008 3:00 PM To: CF-Talk Subject: Re: onApplicationStart What is another way besides creating a temp file to explicitly reset those variables? Is there a way to make the Application expire and restart (sort of speak)? Here's what I use: cffunction name=onRequestStart returntype=void output=false cfif structKeyExists(url,reinitApp) cflock scope=application type=exclusive timeout=5 throwontimeout=true cfset onApplicationStart() /cflock /cfif /cffunction Then add ?reinitApp=1 in any url to restart the app Will ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295787 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: onApplicationStart
You can try putting most of your OnApplicationStart code into cfinclude files and call those cfinclude file in some other reload page. This has an advantage over calling OnApplicationStart again if there are some things that OnApplicationStart does that you don't want to do a second time, such as reinitializing a list of logged-in users. If you just want to reload some application-scope variables or some cached functions, calling the entire OnApplicationStart again might be overkill. Another way to do this is to put conditionals in the OnApplicationStart block that only reinitializes certain sections depending on the input variables (commonly a URL variable). My guess is that you don't actually want to expire the application in order to reload a few variables. If you do want to expire the application, there are ways to do this. Setting the application timeout = 0 is one way. -Mike Chabot On Jan 3, 2008 3:06 PM, Brian Kotek [EMAIL PROTECTED] wrote: You can just call onApplicationStart() again, but be aware that it won't be thread safe as it is when the application starts up. On Jan 3, 2008 3:01 PM, Adkins, Randy [EMAIL PROTECTED] wrote: Question: When using the onApplicationStart within an Application.cfc, lets say I wanted to restart the Application to pickup some changes. Now I know you can cycle the CF Services but I do not have that access to the server. What is another way besides creating a temp file to explicitly reset those variables? Is there a way to make the Application expire and restart (sort of speak)? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295789 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: onApplicationStart
Just note though - that lock isn't really necessary if all you are doing is setting a bunch of simple values in the app scope. And by simple I mean things that dont' need to be single threaded. A CFC stored in the app scope is most likely fine as well. On Jan 3, 2008 1:59 PM, Will Tomlinson [EMAIL PROTECTED] wrote: What is another way besides creating a temp file to explicitly reset those variables? Is there a way to make the Application expire and restart (sort of speak)? Here's what I use: cffunction name=onRequestStart returntype=void output=false cfif structKeyExists(url,reinitApp) cflock scope=application type=exclusive timeout=5 throwontimeout=true cfset onApplicationStart() /cflock /cfif /cffunction Then add ?reinitApp=1 in any url to restart the app Will ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295790 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: onApplicationStart
You can also temporiarly set the session timeout to 0 or some other really short time, let the application expire, then return the timeout to the desired value. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295788 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: onApplicationStart
On Jan 3, 2008 12:24 PM, Raymond Camden [EMAIL PROTECTED] wrote: Just note though - that lock isn't really necessary if all you are doing is setting a bunch of simple values in the app scope. And by simple I mean things that dont' need to be single threaded. A CFC stored in the app scope is most likely fine as well. Careful! That's not necessarily true if there are multiple variables and the integrity of the code relies on them not being set inconsistently. In other words, race condition *can* still apply here depending on how atomic the initialization code is... As for the CFC, if you have init code like this: application.someVar = createObject(component,MyThing); application.someVar.someMethod(42); then that may well not be safe either - in particular if someMethod is actually init! - because the application code may depend on someVar being in at least the state that someMethod() puts it in (and other requests could access application.someVar after the createObject() but before the someMethod() call). A safer way to do that initialization is: var someVar = createObject(component,MyThing); someVar.someMethod(42); application.someVar = someVar; i.e., fully initialize the component before placing it in application scope. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ If you're not annoying somebody, you're not really alive. -- Margaret Atwood ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295800 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: onApplicationStart cftry
It was pretty serious at the time. Seemed to be a problem with the JVM garbage collection but is sorted now. It affected a handful of sites connecting to the SQL server. One of them was failing on the connection storage for the client session varaibles, so I was thinking if this ever happened again it'd be good to be able to test for it in the code. Fingers crossed it won't though :) ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:266583 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: onApplicationStart cftry
I think the idea is to cache the check and not rerun it on every request, which could be wasteful. It is a trade off. I'd probably use onRequestStart, and cache the last check time, and only check once an hour. Maybe. :) On 1/14/07, Richard Cooper [EMAIL PROTECTED] wrote: Hi, I've seen a few examples where this happens, but, I'm a little confused as to why you'd use cftry/cfcatch to test for a DB connection within onApplicationstart. Firstly, would this mean that until the application ends it would consider that the database is unreachable? Secondly, what happens when the DB goes down later on, after the application has started? Wouldn't it be better to have this test within onRequestStart? Lastly (and slightly separately), if I store client details in a DB and this connection is down I'm assuming this problem would occur prior to the onApplicationStart? Would it be best to wrap that in try/catch as well or perhaps even instead of? cftry cfset this.clientStorage = cvars etc... ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:266551 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: onApplicationStart cftry
Gotcha. Thanks Ray. Do you know about the clientStorage bit? I had a problem a while back when I had DB problems and the storage of client and session variables. I'm pretrty sure that this was happening straight away in the first line of application.cfm, within the cfapplication tag. Where by an error was being thrown due to a failed connection. I was thinking that either by wrapping the cfset this.clientStorage or the OnSessionStart function would check for this? ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:266563 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: onApplicationStart cftry
Well, if your client storage fails, thats pretty bad. To me it's the kind of thing you wouldn't try catch as it means a serious problem. On 1/14/07, Richard Cooper [EMAIL PROTECTED] wrote: Gotcha. Thanks Ray. Do you know about the clientStorage bit? I had a problem a while back when I had DB problems and the storage of client and session variables. I'm pretrty sure that this was happening straight away in the first line of application.cfm, within the cfapplication tag. Where by an error was being thrown due to a failed connection. I was thinking that either by wrapping the cfset this.clientStorage or the OnSessionStart function would check for this? ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:266569 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4