code in <perl> sections executed twice in same process?
code in <perl> sections executed twice in same process?
am 16.11.2009 23:10:59 von E R
Hi -
I am using mod-perl 1.3.41 with perl 5.8.9.
The only perl I have in my config file is:
warn "This is a section in process $$ at time @{[time]}\n";
sleep(5);
warn "Done sleeping\n";
When I start it up in single process mode (-X), I'll something like
this on stderr (to the console):
This is a section in process 25597 at time 1258408992
Done sleeping
And also in the error log I'll see:
This is a section in process 25597 at time 1258408998
Done sleeping
The pids will be the same, but the times will be different (about 5
secs. apart.)
Is this "normal", and what can I do so that the code in
sections is only executed once in the parent process?
Thanks,
ER
Re: code in <perl> sections executed twice in same process?
am 16.11.2009 23:41:29 von aw
E R wrote:
....
>
> Is this "normal", and what can I do so that the code in
> sections is only executed once in the parent process?
>
I believe it is "normal", in the sense that Apache actually parses its
configuration at least twice : one time "just for checking", then it
throws everything away and parses it a second time "for real".
Then it will even (probably) run your section again, each time it starts
a new child process.
You probably really want to read the following 2 pages :
http://perl.apache.org/docs/2.0/user/handlers/server.html
http://perl.apache.org/docs/2.0/user/config/custom.html
Re: code in <perl> sections executed twice in same process?
am 17.11.2009 20:48:16 von E R
The sections don't seem to be executed in the children.
Is there a way to determine which pass you are in?
For large mod_perl apps, is there a way to avoid loading your code in twice=
?
Note I am using mod_perl 1.3.41.
Thanks,
ER
On Mon, Nov 16, 2009 at 4:41 PM, Andr=E9 Warnier wrote:
> E R wrote:
> ...
>>
>> Is this "normal", and what can I do so that the code in
>> sections is only executed once in the parent process?
>>
> I believe it is "normal", in the sense that Apache actually parses its
> configuration at least twice : one time "just for checking", then it thro=
ws
> everything away and parses it a second time "for real".
>
> Then it will even (probably) run your section again, each time it starts =
a
> new child process.
>
> You probably really want to read the following 2 pages :
> http://perl.apache.org/docs/2.0/user/handlers/server.html
> http://perl.apache.org/docs/2.0/user/config/custom.html
>
>
Re: code in <perl> sections executed twice in same process?
am 17.11.2009 21:03:16 von Adam Prime
E R wrote:
> The sections don't seem to be executed in the children.
use a PerlChildInitHandler if you want to run code in the children.
> Is there a way to determine which pass you are in?
>
> For large mod_perl apps, is there a way to avoid loading your code in twice?
>
> Note I am using mod_perl 1.3.41.
In mp1, use $Apache::Server::Starting, and $Apache::Server::ReStarting.
see here:
http://perl.apache.org/docs/1.0/guide/config.html#Apache_Res tarts_Twice_On_Start
Adam