Stas Bekman wrote on 11/17/04, 10:34 PM:
> Marcin Kosewski wrote: > > Hi Gurus, > > > > I'm using Apache 1.3.33 with mod_perl 1.29. In Apache httpd.conf > file I'm > > loading external perl directives using: > > PerlRequire startup.pl > > > > I've checked, that during apache startup 'startup.pl' runs two > times. And > > I want, that this script runs only once (because I'm allocating there > > shared memory areas for later use). > > > > So, question is: how to force Apache to run this script exactly once > during > > startup. > > http://perl.apache.org/docs/1.0/guide/config.html#Apache_Restarts_Twice_On_Start > > While this does explain why the server needs to restart twice, I thought I'd mention for Marcin's sake that with 1.3.x $Apache::Server::Starting and $Apache::Server::ReStarting don't (in my experience) work as expected. When I put this slightly modified code in my httpd.conf: <Perl> open(OUT, ">/tmp/log"); print OUT "Called\n"; print OUT "Server is Starting\n" if $Apache::Server::Starting; print OUT "Server is ReStarting\n" if $Apache::Server::ReStarting; close(OUT); </Perl> (I write to a temp file instead of STDERR because under apache 1.3 logging to STDERR during startup isn't always redirected...) The code is _always_ called twice (i.e. when I do a start OR restart) and $Apache::Server::Starting is always true the first time it's called but not the second and $Apache::Server::ReStarting is always false. That is, when starting the server I see: Called Server is Starting Called And when restarting: Called Server is Starting Called Because of this, you can't actually tell the difference between starting and restarting. I know this has been discussed on the list before, but I just thought I'd save him the same frustration I went though trying to do this. --John -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html