Reload Application

48 views
Skip to first unread message

Marco Gil

unread,
Apr 16, 2009, 10:13:04 PM4/16/09
to cfwh...@googlegroups.com

Hi All,

 

I recall reading or even asking this question a while back and after doing a search on google forum for cfwheels couldn’t find it.  I have a page where I adjust settings to my site and after the settings take effect, I want to issue a command to reload the entire application so that users who are currently viewing the site will now see the updated settings.  Is there a command I can issue?

 

Thanks

 

Marco

 

P.S – Apologize for asking this again as I do recall asking but forgot to save the email response.  Thanks guys...

Chris Peters

unread,
Apr 16, 2009, 11:43:08 PM4/16/09
to cfwh...@googlegroups.com
No problem. To reload the application, add this to the end of your URL: ?reload=true

Marco Gil

unread,
Apr 17, 2009, 12:15:22 AM4/17/09
to cfwh...@googlegroups.com

Hi Chris,

 

Is there a way of doing this without using a URL?  I was hoping there was some sort of parameter/function built into CFWheels that would do that for me rather than having to call on a URL.  Thanks

 

Marco

Chris Peters

unread,
Apr 17, 2009, 12:21:19 AM4/17/09
to cfwh...@googlegroups.com
Sorry, I think I only half-read your question. :)

In the PluginManager plugin, this is how it's currently auto-reloading after installing a new plugin:
<cflocation url="?reload=true" addToken="false">

Looks like if you want more of an "API hook" to do it, you'd need to submit a feature request or write a plugin that somehow accomplishes the task.

On Fri, Apr 17, 2009 at 12:15 AM, Marco Gil <marc...@cogeco.ca> wrote:

Hi Chris,

 

Is there a way of doing this without using a URL?  I was hoping there was some sort of parameter/function built into CFWheels that would do that for me rather than having to call on a URL.  Thanks

 

Marco

 

From: cfwh...@googlegroups.com [mailto:cfwh...@googlegroups.com] On Behalf Of Chris Peters
Sent: Apr-16-2009 11:43 PM
To: cfwh...@googlegroups.com
Subject: [cfwheels] Re: Reload Application

 

No problem. To reload the application, add this to the end of your URL: ?reload=true

Per Djurner

unread,
Apr 17, 2009, 5:06:19 AM4/17/09
to cfwh...@googlegroups.com

Marco Gil

unread,
Apr 17, 2009, 7:42:33 AM4/17/09
to cfwh...@googlegroups.com
Hi Per,

Thanks for bring up that thread... One question, what is meant by putting a
lock around the code? You mentioned that in your original reply...

Thanks

Marco

-----Original Message-----
From: cfwh...@googlegroups.com [mailto:cfwh...@googlegroups.com] On Behalf
Of Per Djurner
Sent: Apr-17-2009 5:06 AM
To: cfwh...@googlegroups.com
Subject: [cfwheels] Re: Reload Application


Per Djurner

unread,
Apr 17, 2009, 6:57:47 PM4/17/09
to cfwh...@googlegroups.com
Use cflock and put an exclusive lock on the application scope.

On Fri, Apr 17, 2009 at 1:42 PM, Marco Gil <marc...@cogeco.ca> wrote:
>
> Hi  Per,
>
> Thanks for bring up that thread... One question, what is meant by putting a
> lock around the code?  You mentioned that in your original reply...
>
> Thanks
>
> Marco
>
> -----Original Message-----
> From: cfwh...@googlegroups.com [mailto:cfwh...@googlegroups.com] On Behalf
> Of Per Djurner
> Sent: Apr-17-2009 5:06 AM
> To: cfwh...@googlegroups.com
> Subject: [cfwheels] Re: Reload Application
>
>

Marco Gil

unread,
Apr 19, 2009, 7:13:34 PM4/19/09
to cfwh...@googlegroups.com
Hi Per,

I've tried to do as suggested in your original post and ran into 2 problems:

#1. Using a cflock around the code resulted in a timeout each and every
time, regardless of how long of a timeout I used.

#2. Tried it without the cflock and got the following error:

Variable ONAPPLICATIONSTART is undefined.

The code I have without the lock was as follows:

<cfset onApplicationStart()>

Any suggestions would be appreciated.

P.S - Would this also reset the application for active sessions? If not,
how would I go about doing that? Thanks.

Per Djurner

unread,
Apr 20, 2009, 5:58:18 AM4/20/09
to cfwh...@googlegroups.com
I may have to re-factor the way the locks are done inside Wheels
and/or add more hooks to Wheels events.
In the mean time the only solutions I can think of are:

1) do a cfhttp call to a page in your app with reload=true at the end
of the URL.
2) call onApplicationStart() without a lock inside events/onrequeststart.cfm.

/ Per

On Mon, Apr 20, 2009 at 1:13 AM, Marco Gil <marc...@cogeco.ca> wrote:
>
> Hi Per,
>
> I've tried to do as suggested in your original post and ran into 2 problems:
>
> #1. Using a cflock around the code resulted in a timeout each and every
> time, regardless of how long of a timeout I used.
>
> #2. Tried it without the cflock and got the following error:
>
> Variable ONAPPLICATIONSTART is undefined.
>
> The code I have without the lock was as follows:
>
> <cfset onApplicationStart()>
>
> Any suggestions would be appreciated.
>
> P.S - Would this also reset the application for active sessions?  If not,
> how would I go about doing that?  Thanks.
>

Marco Gil

unread,
Apr 20, 2009, 8:31:32 AM4/20/09
to cfwh...@googlegroups.com
Does the below reset the application for all active sessions as well?

Marco Gil

unread,
Apr 20, 2009, 8:48:40 AM4/20/09
to cfwh...@googlegroups.com
As a f-up, if I'm going to be including the setting to reset the application
on the "onrequeststart" page, then wouldn't it just be the same thing as
moving all the code from the onapplicationstart to onrequeststart? My
application variables will only be changing twice or three times a year and
I was hoping to reset all active and future sessions when these two or three
times occur.

Per Djurner

unread,
Apr 20, 2009, 9:07:20 AM4/20/09
to cfwh...@googlegroups.com
No it doesn't.
In fact, I don't think there is anything built in to ColdFusion at all
that allows you to kill all sessions.
Does anyone else know of a way?

On Mon, Apr 20, 2009 at 2:31 PM, Marco Gil <marc...@cogeco.ca> wrote:
>
> Does the below reset the application for all active sessions as well?
>

Marco Gil

unread,
Apr 20, 2009, 9:09:35 AM4/20/09
to cfwh...@googlegroups.com
Assuming that there is no way to accomplish a reset of all sessions so that
the application variables get reset, should I just go ahead and include all
of those in the onRequeststart instead of in the onApplicationStart?

Only downside in doing so is that I would have to do a Find/Replace in all
of my templates to rename the "application.varname" to "request.varname".
Any other suggestions?

Per Djurner

unread,
Apr 20, 2009, 9:10:19 AM4/20/09
to cfwh...@googlegroups.com
Yes, pretty much.
If you put the onRequestStart code inside a CFIF that makes it only
run once per application it's very similar to having the code in
onApplicationStart.
The difference is that onApplicationStart in single-threaded (i.e.
ColdFusion ensures that it gets run only once even if 1,000 users are
hitting your app at the same time).
If you put the code in onRequestStart you have to handle this yourself
with some locking mechanism.

/ Per

On Mon, Apr 20, 2009 at 2:48 PM, Marco Gil <marc...@cogeco.ca> wrote:
>
> As a f-up, if I'm going to be including the setting to reset the application
> on the "onrequeststart" page, then wouldn't it just be the same thing as
> moving all the code from the onapplicationstart to onrequeststart?  My
> application variables will only be changing twice or three times a year and
> I was hoping to reset all active and future sessions when these two or three
> times occur.
>

Per Djurner

unread,
Apr 20, 2009, 9:12:18 AM4/20/09
to cfwh...@googlegroups.com
I think I would need more info to answer that, i.e. what exactly are
you trying to do?
Post your current code etc.
Thanks.

On Mon, Apr 20, 2009 at 3:09 PM, Marco Gil <marc...@cogeco.ca> wrote:
>
> Assuming that there is no way to accomplish a reset of all sessions so that
> the application variables get reset, should I just go ahead and include all
> of those in the onRequeststart instead of in the onApplicationStart?
>
> Only downside in doing so is that I would have to do a Find/Replace in all
> of my templates to rename the "application.varname" to "request.varname".
> Any other suggestions?
>

Marco Gil

unread,
Apr 20, 2009, 9:17:02 AM4/20/09
to cfwh...@googlegroups.com
Essentially, there's a setting in my application that changes 3 times a
year. It's a hockey league website and there's a field called "League
Status" that's pulled from my dbase. The 3 settings can be:

1. Season
2. Offseason
3. Resigning Period

I would like to restart my application for all sessions when this setting
changes. I have a form I've created that only I have access to which allows
me to adjust these settings. Upon submitting the form, it updates the
database accordingly.

Problem though is you mentioned earlier that all active sessions will still
retain the old setting even after I have changed it. So the only way I can
think of to reset the application for all users is to include it in the
onRequestStart and have it run each and every time a request is submitted -
unless you know of another method??

Per Djurner

unread,
Apr 20, 2009, 9:29:24 AM4/20/09
to cfwh...@googlegroups.com
"all active sessions will still retain the old setting".
Are you saying that you are storing the application variable inside
the session as well?
Otherwise I don't see how sessions would retain the old setting.

Anyway, I found some examples of how to clear sessions here:
http://www.coldfusionchick.com/index.cfm/2008/9/12/Advanced-Session-Management
Not sure if that's officially supported in ColdFusion or if it's an
undocumented feature.

/ Per

On Mon, Apr 20, 2009 at 3:17 PM, Marco Gil <marc...@cogeco.ca> wrote:
>
> Essentially, there's a setting in my application that changes 3 times a
> year.  It's a hockey league website and there's a field called "League
> Status" that's pulled from my dbase.  The 3 settings can be:
>
> 1. Season
> 2. Offseason
> 3. Resigning Period
>
> I would like to restart my application for all sessions when this setting
> changes.  I have a form I've created that only I have access to which allows
> me to adjust these settings.  Upon submitting the form, it updates the
> database accordingly.
>
> Problem though is you mentioned earlier that all active sessions will still
> retain the old setting even after I have changed it.  So the only way I can
> think of to reset the application for all users is to include it in the
> onRequestStart and have it run each and every time a request is submitted -
> unless you know of another method??
>

Marco Gil

unread,
Apr 20, 2009, 9:33:13 AM4/20/09
to cfwh...@googlegroups.com
Sorry...bad explanation on my part. I stored the variables in the
application scope. When I change the setting via the form I submit, all
active sessions still retain the old application variables. I suppose what
I'm asking is how do I go about restarting the application for all users who
are currently on my site once I've made the changes via that form.

-----Original Message-----
From: cfwh...@googlegroups.com [mailto:cfwh...@googlegroups.com] On Behalf
Of Per Djurner
Sent: Apr-20-2009 9:29 AM
To: cfwh...@googlegroups.com
Subject: [cfwheels] Re: Reload Application


Per Djurner

unread,
Apr 20, 2009, 9:38:00 AM4/20/09
to cfwh...@googlegroups.com
Ok, I'm probably not understand exactly what you're trying to do but
try that link I posted, it has some good suggestions to kill all
sessions.

On Mon, Apr 20, 2009 at 3:33 PM, Marco Gil <marc...@cogeco.ca> wrote:
>
> Sorry...bad explanation on my part.  I stored the variables in the
> application scope.  When I change the setting via the form I submit, all
> active sessions still retain the old application variables.  I suppose what
> I'm asking is how do I go about restarting the application for all users who
> are currently on my site once I've made the changes via that form.
>
> -----Original Message-----
> From: cfwh...@googlegroups.com [mailto:cfwh...@googlegroups.com] On Behalf
> Of Per Djurner
> Sent: Apr-20-2009 9:29 AM
> To: cfwh...@googlegroups.com
> Subject: [cfwheels] Re: Reload Application
>
>

Marco Gil

unread,
Apr 20, 2009, 9:55:44 AM4/20/09
to cfwh...@googlegroups.com
Thanks for the input... Checked out the link but it applies more to session
variables. I'll try one more time as far as clarifying the situation - I
admit, I'm not the greatest at explaining these sorts of things.

In the onApplicationStart, I set various application variables including one
in particular called application.leaguestatus. This variable stores the
current state of the league are there are 3 possibilities:

1. Season
2. Offseason
3. Resigning Period

As the league goes from stage to stage, I use a form that only I have access
to in order to change the current state/status of the league. This setting
is stored in my database. I submit the form to change the setting/field in
the database to reflect whatever state I want to put the league into. Once
that change is made via the form, users that are currently on the site will
still have the old state/status since it was stored in the
application.leaguestatus variable when they first logged in.

I need to find a way to re-run the onapplicationstart(), so that the
application variables now take on the new settings, not just for myself as
I'm viewing the site, but for all visitors currently on the site. Does that
make any sense??

Per Djurner

unread,
Apr 20, 2009, 10:31:20 AM4/20/09
to cfwh...@googlegroups.com
Why not just set the application variable on the page that receives
the form submission?
Meaning that you set the initial value in onapplicationstart.cfm and
then change it when you submit the form.
As long as you don't store the value or a copy if it inside the
session itself, everyone should read the new value after the change.

Sorry if that was a really obvious and stupid suggestion ;)

/ Per

On Mon, Apr 20, 2009 at 3:55 PM, Marco Gil <marc...@cogeco.ca> wrote:
>
> Thanks for the input... Checked out the link but it applies more to session
> variables.  I'll try one more time as far as clarifying the situation - I
> admit, I'm not the greatest at explaining these sorts of things.
>
> In the onApplicationStart, I set various application variables including one
> in particular called application.leaguestatus.  This variable stores the
> current state of the league are there are 3 possibilities:
>
> 1. Season
> 2. Offseason
> 3. Resigning Period
>
> As the league goes from stage to stage, I use a form that only I have access
> to in order to change the current state/status of the league.  This setting
> is stored in my database.  I submit the form to change the setting/field in
> the database to reflect whatever state I want to put the league into.  Once
> that change is made via the form, users that are currently on the site will
> still have the old state/status since it was stored in the
> application.leaguestatus variable when they first logged in.
>
> I need to find a way to re-run the onapplicationstart(), so that the
> application variables now take on the new settings, not just for myself as
> I'm viewing the site, but for all visitors currently on the site.  Does that
> make any sense??
>

Marco Gil

unread,
Apr 20, 2009, 10:40:48 AM4/20/09
to cfwh...@googlegroups.com
Lol... not even sure why I didn't think of that... this is a bit
embarrassing :)

Chris Peters

unread,
Apr 20, 2009, 10:54:42 AM4/20/09
to cfwh...@googlegroups.com
Yeah, sometimes we can get so caught up in whatever problem that we're trying to solve that the obvious solution isn't... well... obvious. :)

On Mon, Apr 20, 2009 at 10:40 AM, Marco Gil <marc...@cogeco.ca> wrote:

Lol... not even sure why I didn't think of that... this is a bit
embarrassing :)

Marco Gil

unread,
Sep 27, 2009, 12:46:43 AM9/27/09
to cfwh...@googlegroups.com
Please disregard previous message... Was able to find an old post from Per.
Looks like the trick was to put the call in the onrequeststart.cfm file.
That did the trick. Wrapped it around a CFIF statement that tests for a
reset variable so it that it's only executed when necessary.

Thanks

Reply all
Reply to author
Forward
0 new messages