Reloading FW/1 on every request

499 views
Skip to first unread message

johnfallen

unread,
Aug 11, 2009, 11:37:36 AM8/11/09
to framework-one
Hey List,

Am I totally being a dumb dumb? I can't figure out a way to reload the
framework every request ala the way MG has it's two modes, production
and development.

Anyone have a clean way they are accomplishing this?

Thanks mucho in advance and I'M LOVING FW/1!

AJ Mercer

unread,
Aug 11, 2009, 7:45:26 PM8/11/09
to framew...@googlegroups.com
you can reload via URL reload=true (framework default)

I am guessing you could put in the Application.cfc onRequestStart
URL.reload=true


2009/8/11 johnfallen <johnf...@gmail.com>



--
AJ Mercer
Web Log: http://webonix.net

Sean Corfield

unread,
Aug 13, 2009, 2:08:53 AM8/13/09
to framew...@googlegroups.com
On Tue, Aug 11, 2009 at 11:37 AM, johnfallen<johnf...@gmail.com> wrote:
> Am I totally being a dumb dumb? I can't figure out a way to reload the
> framework every request ala the way MG has it's two modes, production
> and development.

The FW/1 CFC is created on every request because Application.cfc is
created on every request.

Controllers and services are cached. The documentation says use
?reload=true to force the cache to be refreshed.
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies US -- http://getrailo.com/
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

johnfallen

unread,
Aug 13, 2009, 4:38:30 PM8/13/09
to framework-one
@ AJ OOPS! I believe dumb dumb was an apt comment..

"I am guessing you could put in the Application.cfc onRequestStart
URL.reload=true"...

Thats me being a dumb dumb. This solution works wonderfully.

@Sean - dude thanks for FW/1. And YES I read the docs, and good docs
they are!


On Aug 13, 2:08 am, Sean Corfield <seancorfi...@gmail.com> wrote:
> On Tue, Aug 11, 2009 at 11:37 AM, johnfallen<johnfal...@gmail.com> wrote:
> > Am I totally being a dumb dumb? I can't figure out a way to reload the
> > framework every request ala the way MG has it's two modes, production
> > and development.
>
> The FW/1 CFC is created on every request because Application.cfc is
> created on every request.
>
> Controllers and services are cached. The documentation says use
> ?reload=true to force the cache to be refreshed.
> --
> Sean A Corfield -- (904) 302-SEAN
> Railo Technologies US --http://getrailo.com/
> An Architect's View --http://corfield.org/

Dutch Rapley

unread,
Nov 17, 2009, 11:24:39 AM11/17/09
to framew...@googlegroups.com
on CF 9, this also works

    function onRequestEnd() {
        ApplicationStop();
    }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "framework-one" group.
To post to this group, send email to framew...@googlegroups.com
To unsubscribe from this group, send email to framework-on...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/framework-one?hl=en
-~----------~----~----~----~------~----~------~--~---




--
Dutch Rapley
www.dutchrapley.com

Raymond Camden

unread,
Nov 26, 2009, 11:09:50 PM11/26/09
to framework-one
Just want to chime in here - I read the docs too and wondered the same
thing. Most frameworks have a 'reload on every request' setting it
seems - and although it seems to burn people (who don't read the docs
and complain that their app is too slow), it does seem like it would
be nice if FW/1 exposed this as a setting. I'm going to use the
onRequestStart method as defined above.

Dutch Rapley

unread,
Nov 27, 2009, 10:41:53 AM11/27/09
to framew...@googlegroups.com
Ray,

I've found the onRequestStart() method to be a little more consistent, and primarily using that too. onRequestEnd() doesn't get called when errors our thrown or when I abort the reqeust.

--

You received this message because you are subscribed to the Google Groups "framework-one" group.
To post to this group, send email to framew...@googlegroups.com.
To unsubscribe from this group, send email to framework-on...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/framework-one?hl=en.





--
Dutch Rapley
www.dutchrapley.com

Sean Corfield

unread,
Nov 27, 2009, 10:54:53 AM11/27/09
to framew...@googlegroups.com
On Thu, Nov 26, 2009 at 8:09 PM, Raymond Camden <rca...@gmail.com> wrote:
> Just want to chime in here - I read the docs too and wondered the same
> thing. Most frameworks have a 'reload on every request' setting it
> seems - and although it seems to burn people (who don't read the docs
> and complain that their app is too slow), it does seem like it would
> be nice if FW/1 exposed this as a setting. I'm going to use the
> onRequestStart method as defined above.

Well, framework.cfc is created on every request - by definition, since
it's part of your Application.cfc - so only the controllers/services
need reloading. I guess a development mode that essentially forces the
framework not to cache them is what you're looking for?

OK, added in 0.7.8 (available for download right now!):

variables.framework.reloadApplicationOnEveryRequest = true | false (default)

It's a long name so it's really obvious in your Application.cfc so
you're less likely to accidentally go to production with it. It will
refresh the cache and run setupApplication() on every request. If you
remove it - or set it to false - it automatically puts your
application back into production mode on the next request (no need to
reload - so it's not like Fusebox's mode flag).
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies US -- http://getrailo.com/
An Architect's View -- http://corfield.org/

Raymond Camden

unread,
Nov 27, 2009, 11:13:01 AM11/27/09
to framework-one
Perfect - I was thinking about this in the shower (seriously) and I
had thought that FW/1 should definitely default to NOT reloading on
every request. So using the long name and making us explicitly turn it
on is great.

On Nov 27, 9:54 am, Sean Corfield <seancorfi...@gmail.com> wrote:

> OK, added in 0.7.8 (available for download right now!):
>
> variables.framework.reloadApplicationOnEveryRequest = true | false (default)
>
> It's a long name so it's really obvious in your Application.cfc so
> you're less likely to accidentally go to production with it. It will
> refresh the cache and run setupApplication() on every request. If you
> remove it - or set it to false - it automatically puts your
> application back into production mode on the next request (no need toreload- so it's not like Fusebox's mode flag).

Sean Corfield

unread,
Nov 27, 2009, 11:47:19 AM11/27/09
to framew...@googlegroups.com
On Fri, Nov 27, 2009 at 8:13 AM, Raymond Camden <rca...@gmail.com> wrote:
> Perfect - I was thinking about this in the shower (seriously) and I
> had thought that FW/1 should definitely default to NOT reloading on
> every request. So using the long name and making us explicitly turn it
> on is great.

We aim to please :)
--
Sean A Corfield -- (904) 302-SEAN

Bassil Karam

unread,
Nov 28, 2009, 1:44:02 AM11/28/09
to framew...@googlegroups.com
I was thinking about this in the shower
 
We aim to please :)

Hope this thread doesn't get filtered in Saudi Arabia



John Allen

unread,
Nov 30, 2009, 1:29:40 PM11/30/09
to framew...@googlegroups.com
Thanks Sean!
I've wanted this.




--

You received this message because you are subscribed to the Google Groups "framework-one" group.
To post to this group, send email to framew...@googlegroups.com.
To unsubscribe from this group, send email to framework-on...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/framework-one?hl=en.

Will Coleda

unread,
Dec 2, 2009, 1:10:08 PM12/2/09
to framew...@googlegroups.com
On Fri, Nov 27, 2009 at 10:54 AM, Sean Corfield <seanco...@gmail.com> wrote:
> On Thu, Nov 26, 2009 at 8:09 PM, Raymond  Camden <rca...@gmail.com> wrote:
>> Just want to chime in here - I read the docs too and wondered the same
>> thing. Most frameworks have a 'reload on every request' setting it
>> seems - and although it seems to burn people (who don't read the docs
>> and complain that their app is too slow), it does seem like it would
>> be nice if FW/1 exposed this as a setting. I'm going to use the
>> onRequestStart method as defined above.
>
> Well, framework.cfc is created on every request - by definition, since
> it's part of your Application.cfc - so only the controllers/services
> need reloading. I guess a development mode that essentially forces the
> framework not to cache them is what you're looking for?
>
> OK, added in 0.7.8 (available for download right now!):
>
> variables.framework.reloadApplicationOnEveryRequest = true | false (default)

In which method on Application.cfc does this belong? I'd like to set
this in onApplicationStartup conditionally based on the tier I'm
running on (already have some config information broken out this
way.), but it looks like since this generated on every request, I
really want to set it in onRequestStart, onRequest... but nothing
seems to actually reload the service except for the original
reload=true in the URL.

Some sample code in the example app in svn might be helpful.

> It's a long name so it's really obvious in your Application.cfc so
> you're less likely to accidentally go to production with it. It will
> refresh the cache and run setupApplication() on every request. If you
> remove it - or set it to false - it automatically puts your
> application back into production mode on the next request (no need to
> reload - so it's not like Fusebox's mode flag).
> --
> Sean A Corfield -- (904) 302-SEAN
> Railo Technologies US -- http://getrailo.com/
> An Architect's View -- http://corfield.org/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
> --
>
> You received this message because you are subscribed to the Google Groups "framework-one" group.
> To post to this group, send email to framew...@googlegroups.com.
> To unsubscribe from this group, send email to framework-on...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/framework-one?hl=en.
>
>
>



--
Will "Coke" Coleda

Dutch Rapley

unread,
Dec 2, 2009, 1:18:36 PM12/2/09
to framew...@googlegroups.com
Will,

You don't set it in any of the methods.

A good place to put it would be after you set your application specific variables in the "this" scope.

this.name = "MyApplication";
variables.framework.reloadApplicationOnEveryRequest = true

Since Application.cfc gets loaded on every request, so do your framework specific settings. At any given point, you can change the value of reloadApplicationOnEveryRequest  and it'll be reflected on the next request.

-Dutch
Dutch Rapley
www.dutchrapley.com

Sean Corfield

unread,
Dec 2, 2009, 1:26:55 PM12/2/09
to framew...@googlegroups.com
On Wed, Dec 2, 2009 at 10:10 AM, Will Coleda <wco...@gmail.com> wrote:
>> variables.framework.reloadApplicationOnEveryRequest = true | false (default)
>
> In which method on Application.cfc does this belong?

In the same place as all the other framework settings - in the pseudo
constructor outside any method.

> this in onApplicationStartup conditionally based on the tier I'm
> running on

This is set *per-request* - it is not an application setting.

The only way you're going to be able to make this work is to override
onRequestStart() and set it there:

function onRequestStart(targetPath) {
variables.framework.reloadApplicationOnEveryRequest = some complex computation;
super.onRequestStart(targetPath);
}

Given how little the framework does in terms of caching and how I feel
about reloading on every request (I actually do not think it's a good
idea), I'm not going to make it any easier than that - and I recommend
you reconsider why you're really doing this.

Will Coleda

unread,
Dec 2, 2009, 1:49:44 PM12/2/09
to framew...@googlegroups.com
(Resending from my gmail account)

On Wed, Dec 2, 2009 at 1:48 PM, Will Coleda <wi...@coleda.com> wrote:
> On Wed, Dec 2, 2009 at 1:26 PM, Sean Corfield <seanco...@gmail.com> wrote:
>> On Wed, Dec 2, 2009 at 10:10 AM, Will Coleda <wco...@gmail.com> wrote:
>>>> variables.framework.reloadApplicationOnEveryRequest = true | false (default)
>>>
>>> In which method on Application.cfc does this belong?
>>
>> In the same place as all the other framework settings - in the pseudo
>> constructor outside any method.
>>
>>> this in onApplicationStartup conditionally based on the tier I'm
>>> running on
>>
>> This is set *per-request* - it is not an application setting.
>>
>> The only way you're going to be able to make this work is to override
>> onRequestStart() and set it there:
>>
>> function onRequestStart(targetPath) {
>> variables.framework.reloadApplicationOnEveryRequest = some complex computation;
>> super.onRequestStart(targetPath);
>> }
>>
>> Given how little the framework does in terms of caching and how I feel
>> about reloading on every request (I actually do not think it's a good
>> idea), I'm not going to make it any easier than that - and I recommend
>> you reconsider why you're really doing this.
>
> I had hoped that the setting would persist across requests, so that I
> could set it once and forget it; I already have code that is being
> invoked once on application startup based on the tier; having all this
> code in one place would be a win, but that's fine, I can add a small
> cfif in onRequestStart [0].
>
> The reason I want this to be conditional in the code:
>
> 1) I need to deploy this application to multiple tiers. (developer's
> desktops, dev tier, stage tier, production tier.) - Having to change
> this setting manually every time the app is deployed is a pita. (The
> condition, btw, is just <cfif Application.Stage EQ "dev"> ... </cfif>)
>
> 2) Our team very much needs this, at least for their desktops: I have
> already had developers on the project lose time trying to diagnose why
> their changes to services on their dev machines are not happening.
> When you're trying to do rapid development, adding (or even
> remembering you need to add) a "reload=true" for every commit is a
> time sink. (conversely, having each developer add the autoreload logic
> and then remember to NOT commit it back to the source code repository
> along with real changes is also a PITA).
>
> So, now my developers can edit the service methods, save, and
> immediately test via the browser, and when it goes to stage for QA or
> prod for the users, everything will automatically get cached. Every
> tier is happy.
>
> [0] And thank you for this sample, which points out that I needed to
> be doing this /before/ the invocation of
> super.onRequestStart(targetPath); now the conditional is working, the
> reload is working, and everything's cool. =-)
>
> --
> Will "Coke" Coleda
>



--
Will "Coke" Coleda

Dutch Rapley

unread,
Dec 2, 2009, 2:08:07 PM12/2/09
to framew...@googlegroups.com
> 1) I need to deploy this application to multiple tiers. (developer's
> desktops, dev tier, stage tier, production tier.) - Having to change
> this setting manually every time the app is deployed is a pita. (The
> condition, btw, is just <cfif Application.Stage EQ "dev"> ... </cfif>)

When you deploy, don't you have to change the value you set for application.stage to 'production'? How's that different than changing the value of variables.framework.reloadApplicationOnEveryRequest depending on the environment you're in? The whole reason reloadApplicationOnEveryRequest exists is so developers don't have to pass reload=true in the query string to refresh everything in development environments. While Sean did add this setting as a feature, he wasn't necessarily a fan of it.

If you really want use environment based settings (no just for reloading), I'm doing this in my Application.cfc. Granted, I'm not using  a 'reload' boolean, so I'm just putting it here for example purposes.

    variables.settings.env = cgi.server_name;

    /* default application config settings */
    variables.settings.defaults = {
        reload = false
    };
   
    /* default local dev environment settings */
    variables.settings['my-local-dev.localhost] = {
        reload = true
    };

    function getSettings() {
        StructAppend(variables.settings.defaults, variables.settings[variables.settings.env], true);
        return variables.settings.defaults;
    }

In onRequestStart(), you can simply call getSettings().reload

I actually use getSettings() when I instantiate my bean factory to set up on environment specific settings (i.e. whether to send emails or log them to a database).

-Dutch

Will Coleda

unread,
Dec 2, 2009, 2:36:22 PM12/2/09
to framew...@googlegroups.com
On Wed, Dec 2, 2009 at 2:08 PM, Dutch Rapley <dutch....@gmail.com> wrote:
>> > 1) I need to deploy this application to multiple tiers. (developer's
>> > desktops, dev tier, stage tier, production tier.) - Having to change
>> > this setting manually every time the app is deployed is a pita. (The
>> > condition, btw, is just <cfif Application.Stage EQ "dev"> ... </cfif>)
>
> When you deploy, don't you have to change the value you set for
> application.stage to 'production'?
>
> How's that different than changing the
> value of variables.framework.reloadApplicationOnEveryRequest depending on
> the environment you're in?

I discover the value at application launch time. No code needs to be
changed for deploying to the various tiers, nothing needs to be passed
in to config it -- it's based on values in the CGI scope.

> The whole reason reloadApplicationOnEveryRequest
> exists is so developers don't have to pass reload=true in the query string
> to refresh everything in development environments.

Which is exactly what I'm using it for. =-)

> While Sean did add this
> setting as a feature, he wasn't necessarily a fan of it.
>
> If you really want use environment based settings (no just for reloading),
> I'm doing this in my Application.cfc. Granted, I'm not using  a 'reload'
> boolean, so I'm just putting it here for example purposes.
>
>     variables.settings.env = cgi.server_name;
>
>     /* default application config settings */
>     variables.settings.defaults = {
>         reload = false
>     };
>
>     /* default local dev environment settings */
>     variables.settings['my-local-dev.localhost] = {
>         reload = true
>     };
>
>     function getSettings() {
>         StructAppend(variables.settings.defaults,
> variables.settings[variables.settings.env], true);
>         return variables.settings.defaults;
>     }
>
> In onRequestStart(), you can simply call getSettings().reload
>
> I actually use getSettings() when I instantiate my bean factory to set up on
> environment specific settings (i.e. whether to send emails or log them to a
> database).
>
> -Dutch
>

Sean Corfield

unread,
Dec 3, 2009, 1:53:02 PM12/3/09
to framew...@googlegroups.com
On Wed, Dec 2, 2009 at 10:49 AM, Will Coleda <wco...@gmail.com> wrote:
>> 1) I need to deploy this application to multiple tiers. (developer's
>> desktops, dev tier, stage tier, production tier.) - Having to change
>> this setting manually every time the app is deployed is a pita. (The
>> condition, btw, is just <cfif Application.Stage EQ "dev"> ... </cfif>)

So do this:

if ( structKeyExists( application, 'stage' ) )
variables.framework.reloadApplicationOnEveryRequest =
application.stage is 'dev';
Reply all
Reply to author
Forward
0 new messages