Re: [ROOT] [Carrot] Persistant Object in Apache [long post]

From: Ashley Cambrell (ash@freaky-namuh.com)
Date: Wed Apr 03 2002 - 19:50:22 MEST


Hi Valeriy,

Thanks for putting up with me :-).

Valeriy Onuchin wrote:

> Hi Ashley,
>I truncated discussion a ltl bit
>
>Ashley Cambrell wrote:
>
>>Hi Valeriy,
>>
>>
>>I don't quite understand what TApacheCache is used for.  There doesn't
>>seem to be anyway of putting objects in the cache.. [?]
>>
>
>TApacheCache is used for server-side caching
>http://carrot.cern.ch/CarrotExamples/tutorial/tut6-1.chtml
><snip>
>
Aaah Ok.. cached html output.

>><snip>
>>
>
>The Apache web server follows the model of a process farm:
>It has a parent process which spawns several children processes.
>Whenever a client request arrives at the server, it is handled by a child process.
>If the number of simultaneous requests exceeds the number of existing children,
>a new child process is spawned.  When a child process terminates, a new one is spawned.
>
>CarrotChildInit.C script is executed whenever server spawns a new child.
>CarrotChildExit.C script is executed when apache child exits.
>
As Apache may use an existing child process, you can't use these scripts 
to centralize things that must be run at every /client connection/.

>>But Apache is usually configured so that
>>
>>StartServers 100
>>MinSpareServers 100
>>MaxSpareServers 200
>>
Over the top example..  I was trying to say that if it was configured 
(badly) like this then the CarrotChildInit.C script would basically only 
run once like GloablInit.C

>
><snip>
>
>
>You can load user defined libs at CarrotChildInit.C script
>and execute functions as similar as it is done by rootlogon.C
>script in normal ROOT session.
>
I think I'm on the wrong track.  

I was looking for a way to hide things (sessionid creation, session 
startup, setting of cookie etc) that should be done at every client 
connection without the user having to explicitly do anything.  A "It 
just does it" mentality like PHP.  (With PHP it does stuff like 
re-writing urls so that it passes the PHPSESSID if cookies aren't turned 
on, and such things)  I guess it would be fairly easy to bury most of 
the stuff needed for sessions in a session class.  

There are two sides to this.  How to bury things that need to always 
happen as part of the Carrot frame work (that needs to run on every 
client connection), and how to let the user run (/bury for 
maintainablility) stuff that needs to run on every client connection.

It would be good if you could register functions to run at the start of 
a script and at the end of the script so the user didn't.

Eg In CarrotChildInit.C
gSystem->AddAtClientConnect("gSession->startSession");
gSystem->AddAtClientConnect("fSomeClass->checkPageAccess");
gSystem->AddAtClientDisconnect("gSession->endSession");
gSystem->AddAtClientDisconnect("gSession->ReWriteUrls");

So that when test_1.C is called the use can just do:
//###################-- test_1.C
//output html
TObject uid = gSession->GetValue("userid");
//do more stuff
//###################-- test_1.C
and test 2 could be
//###################-- test_2.C
//output html
TObject uid = gSession->GetValue("userid");
//do more stuff
//###################-- test_2.C

instead of
//###################-- test_1.C
gSession->startSession();
fSomeClass->checkPageAccess();

//output html
TObject uid = gSession->GetValue("userid");
//do more stuff

gSession->ReWriteUrls();
gSession->endSession();
//###################-- test_1.C
//###################-- test_2.C
gSession->startSession();
fSomeClass->checkPageAccess();

//output html
TObject uid = gSession->GetValue("userid");
//do more stuff

gSession->ReWriteUrls();
gSession->endSession();
//###################-- test_2.C

Then, to add a new function to be run at client connect (for all pages), 
you'd only have to add the entry to CarrotChildInit.C and not edit every 
file in your website to add the function call to.

With Carrot you can't seem to do:

//###################-- global.C

//define function checkSomething
void checkSomething()
{
    //do stuff
}

//run function checkSomething
checkSomething();
//###################-- global.C

//###################-- theWebPage.C

#include "global.C" //<-- runs checkSomething()

//do normal stuff

//###################-- theWebPage.C

where as in PHP you can, which makes it easier to move functions that 
are run at every page into it's own maintainable file.

Sorry if everything sounds like complete gibberish.  I don't think my 
explaination of what I'm trying to convey is clear.  (It's almost 4:00am 
here, maybe that's why  ;-) )

>
>HTH.     Regards.    Valeriy
>
Thanks Valeriy,

Ashley Cambrell



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:48 MET