Server.cfc (Web.cfc)

165 views
Skip to first unread message

Michael Offner

unread,
Oct 10, 2013, 5:10:07 PM10/10/13
to ra...@googlegroups.com
ACF has introduced the Server.cfc with ACF9 (i think), but until now, nobody has asked to add support for this to Railo.
I have also found only one short blog post about it, so i think it is really not a popular feature.
Does anyone of you use it or have you tried?
I have tried it today for a short period, to find out what restriction this feature has.
i looks to me that it is extremely restricted.
i was only able to get it working with a "hello world", when i start adding code, it was breaking.

so my question is, would it make sense to have this in railo, when it works, i mean that you can do everything without restrictions (of course with a dummy request and response object). 
What i not like about the Server.cfc, is that there is only one template executed per server, i would prefer to have a template for every webcontext, so let's say a Web.cfc in the webroot that works out of the box.

Of Course with support for "onServerStart" and "onServerStop".

What do you think?

Micha









--
/micha

Michael Offner CTO Railo Technologies GmbH

Matt Quackenbush

unread,
Oct 10, 2013, 5:18:32 PM10/10/13
to ra...@googlegroups.com
I've never used it (actually not sure I was even aware of its existence) and not sure I would, but if it's to be added, I agree with your suggestions of making it useful and per web context.

Without having a dog in this fight, I don't have any feelings one way or the other on whether this is a good idea or not. However, I will ask the same questions as in other threads:

* What is the benefit?
* What other, more widely-used features/additions/fixes would be put on the back burner to devote resources to such an (apparently) edge case feature request?




--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/railo/CAJVB4jeCn5iM8FYFmu-fx-XorkZLy47dEtQdN_rOXfWA5d8%2BVA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Geoff Parkhurst

unread,
Oct 10, 2013, 6:02:52 PM10/10/13
to ra...@googlegroups.com
Never used it myself, though I could imagine some kind of "warm up the
cache" function before some poor soul gets the first 'cold' page view
of a site...

Or maybe a "get the latest source code from somewhere" after a reboot.

Or "tell my load balancer I'm up and running"
> https://groups.google.com/d/msgid/railo/CAKa5oq%2BnFmW340jmkrh7QFECSC36RucgOLDk-nQZdGgtUPMi9w%40mail.gmail.com.

Michael Offner

unread,
Oct 10, 2013, 6:19:50 PM10/10/13
to ra...@googlegroups.com
that is exactly the point, i want to find out how "edge case" a feature like this really is.
adding support for this is not really a big deal, because we already have most tools in place for it.
- triggers for event (onServerStart and onServerStop)
- creating a dummy PageContext (request representation)

Railo as application for example does a lot at startup, you can do some initial stuff, before you get the first request.
Initialize a framework, get information from a remote resource...

You can start a control thread (with cfthread) , that runs as long it get stopped by "onServerStop", that does some maintenance or whatever.
of course you could do all of this, with a gateway or a scheduled taks, but this way is easier and needs no configuration in the admin. when this works out of the box, you can deploy your application, without the need of registering a gateway/scheduled tasks.

Micha
 


2013/10/10 Matt Quackenbush <quack...@gmail.com>

For more options, visit https://groups.google.com/groups/opt_out.

Igal @ getRailo.org

unread,
Oct 10, 2013, 6:32:25 PM10/10/13
to ra...@googlegroups.com
I usually put some reusable read-only data in the Server scope, for example an array of Countries and States/Provinces, which I use across different applications, or IP-to-country data which resolves IP addresses to countries.  this is a large dataset and there really is no reason to keep more than one copy of it in memory.

data like that is not modified throughout the lifecycle of the server so in Application.cfc onApplicationStart() I lock the server scope and put it there, but I always have to account for locking and race conditions.

in this case, Server.cfc makes more sense to me than Web.cfc;  for me Web-Context and Application is usually the same thing.


Igal

For more options, visit https://groups.google.com/groups/opt_out.

-- 
Igal Sapir
Railo Core Developer
http://getRailo.org/

AJ Mercer

unread,
Oct 10, 2013, 6:42:24 PM10/10/13
to ra...@googlegroups.com
With in a web context you can have multiple applications - folders with their own Application.cfc / Application.cfm


On 11 October 2013 06:32, Igal @ getRailo.org <ig...@getrailo.org> wrote:
​<snip>


in this case, Server.cfc makes more sense to me than Web.cfc;  for me Web-Context and Application is usually the same thing.


Igal

Igal @ getRailo.org

unread,
Oct 10, 2013, 6:43:59 PM10/10/13
to ra...@googlegroups.com
I am aware of the difference.  that's why I wrote "for me".
--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

For more options, visit https://groups.google.com/groups/opt_out.

Bruce Kirkpatrick

unread,
Oct 10, 2013, 8:34:03 PM10/10/13
to ra...@googlegroups.com
I decided a while back that putting data in server scope is very bad since it makes it harder for your app to co-exist with other apps (especially other versions of your own app) or with shared hosting.  Imagine if people install 10 versions of Mura on a single instance.  If they all had data mixing in server scope, it would be a nightmare.  I also realized it was easier to warm up and reset the cache when all my sites were running on 1 application name, 1 context because I don't have to make separate requests just to get access to another domain's application scope.  Each domain is just a key in the same application scope now.

As a rule, I'd only want to use this if it was implemented as web.cfc so that the code could be distributed along with the rest of my project and not interfere with supporting multiple versions of my app.  Having one file for entire server would be less useful.  The only benefit of server.cfc would be a guarantee that it only ran the code once and is guaranteed to be thread-safe.  If 2 identical web.cfc exist in separate contexts, then both would run and you'd have to ensure that isn't dangerous with validation & locking.

I also don't make a distinction between Application and context yet like Igal mentioned.   Perhaps, if we had another new feature called the "context scope", web.cfc could have access to the context scope instead of just server scope.  All your apps in that context could share data securely instead of the less secure server scope.  That is one way to justify creating web.cfc instead of server.cfc.  

Maybe another method could be made for onServerStartAfterUncleanShutdown().  You could keep track of whether Railo shut down properly last time or if it was killed suddenly.

Alex Skinner

unread,
Oct 11, 2013, 2:27:05 AM10/11/13
to ra...@googlegroups.com

I would use it if it was there. For cloud architectures where on VM provision you want to register with a central job server or load balancer to say

Hi I'm worker50 I'm alive.

Obviously I don't need that type of feature for my SMTP listeners as event gateways have automatic start which works well.

So I guess I could write it that way too

A

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

Alex Skinner

unread,
Oct 11, 2013, 2:29:11 AM10/11/13
to ra...@googlegroups.com

I like your idea of a CFC per context that's much note useful, +1

Andrew Scott

unread,
Oct 11, 2013, 2:42:43 AM10/11/13
to ra...@googlegroups.com
I can think of a multitude of reasons you would want it, but I am like Geoff & Matt, personally never used it. But I would like to think that it is a very nice to have feature, in a lot of peoples eyes.


Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/



Michael Offner

unread,
Oct 11, 2013, 3:22:54 AM10/11/13
to ra...@googlegroups.com
but i think you agree that a onServerStart makes no sense in the Application.cfc, because onServerStart is not triggered by a request, railo has to search the complete website including all mappings for application.cfcS

Micha


2013/10/11 Igal @ getRailo.org <ig...@getrailo.org>

For more options, visit https://groups.google.com/groups/opt_out.



--

Michael Offner

unread,
Oct 11, 2013, 3:30:18 AM10/11/13
to ra...@googlegroups.com
yeah the idea about a "web scope" already has crossed my mind. but i'm not sure if this is really needed. you can simply do something like this
server[cgi.server_root].whatever=1;
myself, i never missed it so far in my programming

Micha









2013/10/11 Bruce Kirkpatrick <br...@farbeyondcode.com>

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

For more options, visit https://groups.google.com/groups/opt_out.

Andrew Penhorwood

unread,
Oct 11, 2013, 7:22:26 AM10/11/13
to ra...@googlegroups.com
I can see use cases for onServerStart and onServerStop but in the last 14 years I have never needed this functionality.  Most of my applications are self-contained.

What methods besides onServerStart and onServerStop would be available in server.cfc?

Andrew Penhorwood

James Kilford

unread,
Oct 11, 2013, 7:25:48 AM10/11/13
to ra...@googlegroups.com
Micha, 

I feel a bit torn on this feature.  I've never used it, and never needed it so far... but things are changing in the way we develop, so it might be quite useful in the future.  

For example, as people go to virtualised environments, with lots of on-demand instances starting and stopping, it would be great to do these switch-on and switch-off tasks such as object instantiation, service registration, static data download, update application code, etc. 

I would say it's worth doing if it's not too difficult / time-consuming.  

As for the Web.cfc vs Server.cfc, I think both.  It's good for projects to be able to worry about only their own concerns, but perhaps having the Server.cfc as well for familiarity, especially if it can be deployed separately from a context.  Is that the idea?  That it lives somewhere outside of the contexts?  This I think would be useful for checking out latest code, say.  You have the one Server.cfc that you deploy onto a base image machine (think Amazon AMI), then the Server.cfc downloads the latest app code from S3 when the server starts.  

This mechanism is useful because having a machine in a load balancer cluster with old app code could be tiresome if it created random problems that affect 1 in n visitors.  Having a nice empty skeleton machine that auto-deploys would be perfect.  Obviously this could be done through the OS, but it's fab, for us Railo developers, to have this.

Many thanks, 

James


--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

Jochem van Dieten

unread,
Oct 11, 2013, 10:57:48 AM10/11/13
to ra...@googlegroups.com
On Thu, Oct 10, 2013 at 11:10 PM, Michael Offner <mic...@getrailo.com> wrote:
ACF has introduced the Server.cfc with ACF9 (i think), but until now, nobody has asked to add support for this to Railo.

 

I have also found only one short blog post about it, so i think it is really not a popular feature.
Does anyone of you use it or have you tried?

All my ACF applications have a mechanism that verifies the server configuration tied to the onServerStart(). It does checks on available resources such as filesystems, mailservers, database servers, webservices ets.
In Railo I have it tied to the onApplicationStart() for lack of a better place to do so, but it is really suboptimal since stuff like this.ormenabled and this.mappings happens before the onApplicationStart() and functionally depends on the availability of filesystems and database servers.

 
What i not like about the Server.cfc, is that there is only one template executed per server, i would prefer to have a template for every webcontext, so let's say a Web.cfc in the webroot that works out of the box.

I don't really care if it is an onContextStart() or an onServerStart(). I would just like to have the opportunity to tie code to an event that occurs before an actual application request is received.

Jochem


--
Jochem van Dieten
http://jochem.vandieten.net/

Igal @ getRailo.org

unread,
Oct 11, 2013, 11:30:25 AM10/11/13
to ra...@googlegroups.com
oh, I Absolutely agree!


Igal

For more options, visit https://groups.google.com/groups/opt_out.

colbylitnak

unread,
Oct 11, 2013, 11:35:23 AM10/11/13
to ra...@googlegroups.com
Some of our applications have 15-30 second startup times. We use a tomcat lifecyclelistener to make a request to our apps when the container starts up, so the first user doesn't have to feel it. I think OnServerStart is a perfect alternative to using tomcat features. Funny enough the name of the remote function the listener calls is named "onServerStart"

Igal @ getRailo.org

unread,
Oct 11, 2013, 12:04:38 PM10/11/13
to ra...@googlegroups.com
on my applications there is traffic all the time (if not from users then search engine bots) so onApplicationStart() is triggered fast, but still -- I have to tale care of locking and running the setup on a separate thread, and in that meantime I kill all other requests with 503 so that they don't queue up.

bottom line -- I find onServerStart() very useful.
--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

For more options, visit https://groups.google.com/groups/opt_out.

Brian Meloche

unread,
Oct 11, 2013, 3:43:15 PM10/11/13
to ra...@googlegroups.com
I used onServerStart() for a server where all traffic came in via a socket gateway. The gateway would invoke a controller CFC. When the controller CFC wasn't called via an HTTP request, it did not respect the application scope, so I had things stored in the server scope and used Server.cfc much like you would an Application.cfc.

Hopefully, that helps.

Sincerely,


Brian Meloche
@coofuushun


AJ Mercer

unread,
Oct 11, 2013, 7:28:28 PM10/11/13
to ra...@googlegroups.com
could the server.cfc be used for other thinks like
  • ping - server is up
  • heath check - something that would say 80% utilised; for cluster load balancing
  • get list of contexts and their status

I think web.cfc would be good for completeness sake. As soon as people start using the server.cfc they will think of things they want to do at the context level.


Is there a list of all railo events that we can review, including yet to be implemented?




--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

For more options, visit https://groups.google.com/groups/opt_out.



--

Pete Freitag

unread,
Oct 14, 2013, 10:26:08 AM10/14/13
to ra...@googlegroups.com
Hi Micha,

I would love to be able to define an onRequestStart function in server.cfc, this is mainly for security purposes (eg FuseGuard) but I think there could be other use cases as well.

--
Pete Freitag

Igal @ getRailo.org

unread,
Oct 14, 2013, 12:11:10 PM10/14/13
to ra...@googlegroups.com
+2

even if we just get CGI, URL, and http headers there.
--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

For more options, visit https://groups.google.com/groups/opt_out.

-- 
Igal Sapir
Railo Core Developer
http://getRailo.org/

AJ Mercer

unread,
Oct 14, 2013, 6:21:08 PM10/14/13
to ra...@googlegroups.com
would the event bubble up?
So onRequestStart() would go to
  1. Application.cfc
  2. Contect.cfc
  3. Server.cfc
  4. Cluster.cfc ??

And at each point there would be a way to say the request has been handled and to stop.


On 15 October 2013 00:11, Igal @ getRailo.org <ig...@getrailo.org> wrote:
+2

even if we just get CGI, URL, and http headers there.



On 10/14/2013 7:26 AM, Pete Freitag wrote:
Hi Micha,

I would love to be able to define an onRequestStart function in server.cfc, this is mainly for security purposes (eg FuseGuard) but I think there could be other use cases as well.

--
Pete Freitag

Dawesi

unread,
Dec 7, 2014, 7:15:03 AM12/7/14
to ra...@googlegroups.com
I gave up on waiting for this (blooming purists - everything is an edge case in my book. no-one uses many of the non-edge features of railo, yet they aren't called edge?) use IIS to do warming ATM, as Railo is behind on this feature...

one thing I CANT do right now, would be great to be able to put component.cfc into ram file so all components could be pointed to a ram file instead of disk file tho, but because I can only do that after application.cfc is instantiated, it would defeat the point as it's an admin settting (happy for any enlightenment here)

Also don't assume because people aren't answering here for a year or so that they aren't using railo to develop... the list just doesn't give or have the answers I need generally, so I often look elsewhere.

Dawesi

Michael Offner

unread,
Dec 7, 2014, 8:14:38 AM12/7/14
to ra...@googlegroups.com
See my comments  between the lines 

Micha


Am Sonntag, 7. Dezember 2014 schrieb Dawesi :
I gave up on waiting for this (blooming purists - everything is an edge case in my book. no-one uses many of the non-edge features of railo, yet they aren't called edge?) use IIS to do warming ATM, as Railo is behind on this feature...

one thing I CANT do right now, would be great to be able to put component.cfc into ram file so all components could be pointed to a ram file instead of disk file tho, but because I can only do that after application.cfc is instantiated, it would defeat the point as it's an admin settting (happy for any enlightenment here)
I'm not sure if I get this right, do you mean with component.cfc the component every other component is extending? If so be aware that Railo has a very strong caching for this component because this component mostly never change. 
If you speak about components in general, you can simply do a component mapping that point to the ram resource and then copy your component to that resource.
You can even let the cfclasses directory point to the ram resource, so even the compiled class files are then in ram...

 

Also don't assume because people aren't answering here for a year or so that they aren't using railo to develop... the list just doesn't give or have the answers I need generally, so I often look elsewhere.

Dawesi

On Friday, 11 October 2013 08:10:07 UTC+11, Michael Offner wrote:
ACF has introduced the Server.cfc with ACF9 (i think), but until now, nobody has asked to add support for this to Railo.
I have also found only one short blog post about it, so i think it is really not a popular feature.
Does anyone of you use it or have you tried?
I have tried it today for a short period, to find out what restriction this feature has.
i looks to me that it is extremely restricted.
i was only able to get it working with a "hello world", when i start adding code, it was breaking.

so my question is, would it make sense to have this in railo, when it works, i mean that you can do everything without restrictions (of course with a dummy request and response object). 
What i not like about the Server.cfc, is that there is only one template executed per server, i would prefer to have a template for every webcontext, so let's say a Web.cfc in the webroot that works out of the box.

Of Course with support for "onServerStart" and "onServerStop".

What do you think?

Micha









--
/micha

Michael Offner CTO Railo Technologies GmbH

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.
Reply all
Reply to author
Forward
0 new messages