You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Drew Wilson <dr...@viralon.com> on 2001/03/06 02:24:10 UTC

mod_perl startup sequence?

I'm confused about when mod_perl loads Perl Modules. It appears my perl
module gets loaded twice: once when the log writes to stdout, and once
when the log message is written to error-log.

I would expect my module to only get loaded once. Why twice?

To help me trace loading, I added "print STDERR" statements to my .conf
file and my perl module. To my surprise, log messages go to the console,
and messages go the log file 30 milliseconds later. Also, the
Apache::Server::Starting is 1 first time through, and 0 the second time
through. NOTE: PerlFreshRestart is NOT defined.

For example, this appears on my console:
# .conf started at 983839924.241642, Starting = 1, ReStarting=0
# wierd.pm started at 983839924.274978, Starting = 1, ReStarting=0
# .conf finished at 983839924.277637

And this appears in my error-log:
# .conf started at 983839924.285614, Starting = 0, ReStarting=0
# wierd.pm started at 983839924.292273, Starting = 0, ReStarting=0
# .conf finished at 983839924.294823

Notice the difference in execution times (1st ends at 983839924.277637
and the 2nd one starts at 983839924.285614).


Here's my simplified .conf
<Perl>
	use Time::HiRes qw( time );
	print STDERR "# .conf started at " . time() . "\n";
</Perl>	
PerlModule wierd.pm
<Location /my_wierd>
	SetHandler	perl-script
	PerlHandler	wierd
</Location>
<Perl>
	use Time::HiRes qw( time );
	print STDERR "# .conf finished at " . time() . "\n";
</Perl>	


And here's my simplified wierd.pm
package wierd;
use strict;
use Time::HiRes qw( time );

print STDERR "# wierd.pm loaded at " . time() . "\n";
return 1;


TIA,

drew
==============

Re: mod_perl startup sequence?

Posted by Paul Cotter <pr...@bellsouth.net>.
mod_perl startup sequence?From: Drew Wilson 
  To: modperl@apache.org 
  Sent: Monday, 05 March, 2001 08:24 PM
  Subject: mod_perl startup sequence?


  I'm confused about when mod_perl loads Perl Modules. It appears my perl module gets loaded twice: once when the log writes to stdout, and once when the log message is written to error-log.

  I would expect my module to only get loaded once. Why twice? 

  To help me trace loading, I added "print STDERR" statements to my .conf file and my perl module. To my surprise, log messages go to the console, and messages go the log file 30 milliseconds later. Also, the Apache::Server::Starting is 1 first time through, and 0 the second time through. NOTE: PerlFreshRestart is NOT defined.

  For example, this appears on my console: 
  # .conf started at 983839924.241642, Starting = 1, ReStarting=0 
  # wierd.pm started at 983839924.274978, Starting = 1, ReStarting=0 
  # .conf finished at 983839924.277637 

  And this appears in my error-log: 
  # .conf started at 983839924.285614, Starting = 0, ReStarting=0 
  # wierd.pm started at 983839924.292273, Starting = 0, ReStarting=0 
  # .conf finished at 983839924.294823 

  Notice the difference in execution times (1st ends at 983839924.277637 and the 2nd one starts at 983839924.285614). 


I have a similar confusion. My httpd.conf opens with

LoadModule perl_module modules/mod_perl.so
<Perl>
    open FIL, ">>c:\\a.txt";
    print FIL "\nStart httpd.conf pid=$$";
    close FIL;
</Perl>

After starting Apache I have the following in c:\a.txt

Start httpd.conf pid=2144
Start httpd.conf pid=2144
Start httpd.conf pid=2072

startup.pl is also run three times.

The config is win2k, apache 1.3.17, mod_perl 1.25. The taskmanager shows two apache.exe's running and two cidaemons. I could understand a fallback apache, bit I cannot see why the code is executed twice for the same pid.

Can someone explain this behaviour - or tell me where I should go to read about it. (politely!-)

TVM - Paul Cotter