You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by David Wheeler <da...@kineticode.com> on 2003/02/21 03:52:23 UTC

[mp1] Alternative for CHECK

Hi All,

I'm writing a module that will run in Apache and has important code 
that needs to run after all modules have loaded but before Apache forks 
and starts serving requests. Since mod_perl 1.x ignores CHECK and INIT 
blocks, and BEGIN blocks run too early for what I'm doing, I was 
wondering if there's a hook in the mod_perl API where I can run some 
code just before before Apache forks and starts serving requests?

If you must know what I'm doing, I'm looking for stuff in the symbol 
table.

TIA!

David

-- 
David Wheeler                                     AIM: dwTheory
david@kineticode.com                              ICQ: 15726394
                                                Yahoo!: dew7e
                                                Jabber: Theory@jabber.org
Kineticode. Setting knowledge in motion.[sm]


Re: [mp1] Alternative for CHECK

Posted by David Wheeler <da...@kineticode.com>.
On Thursday, February 20, 2003, at 10:51  PM, Stas Bekman wrote:

> Why not? Use a separate module to drive the others?
>
> package My::PostConfig;
>
> BEGIN {
>   # whatever needs to be done for other modules
> }
> 1;
>
> startup.pl:
> -----------
> use My::PostConfig

Excellent point, and a quick experiment on my end shows that this does 
do what I need. I have two different modules to be loaded for this 
project, so I just make sure that one loads after the other does, and 
it all works.

Thanks for the nudge, Stas, it was just what I needed.

Regards,

David

-- 
David Wheeler                                     AIM: dwTheory
david@kineticode.com                              ICQ: 15726394
                                                Yahoo!: dew7e
                                                Jabber: Theory@jabber.org
Kineticode. Setting knowledge in motion.[sm]


Re: [mp1] Alternative for CHECK

Posted by Stas Bekman <st...@stason.org>.
David Wheeler wrote:
> On Thursday, February 20, 2003, at 09:41  PM, Stas Bekman wrote:
> 
>> startup.pl?
> 
> 
> Won't work too well in a module, I think. I have a workaround for my  
> problem for now, but it ain't pretty.

Why not? Use a separate module to drive the others?

package My::PostConfig;

BEGIN {
   # whatever needs to be done for other modules
}
1;

startup.pl:
-----------
use My::PostConfig


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: [mp1] Alternative for CHECK

Posted by David Wheeler <da...@kineticode.com>.
On Thursday, February 20, 2003, at 09:41  PM, Stas Bekman wrote:

> startup.pl?

Won't work too well in a module, I think. I have a workaround for my  
problem for now, but it ain't pretty.

> in 2.0 you have: PerlPostConfigHandler
> http://perl.apache.org/docs/2.0/user/handlers/ 
> server.html#PerlPostConfigHandler

Oooh, yes, that's exactly what I want. Will have to port it all when  
the time comes. Waiting for the mod_perl 2 momentum, now,

Regards,

David

-- 
David Wheeler                                     AIM: dwTheory
david@kineticode.com                              ICQ: 15726394
                                                Yahoo!: dew7e
                                                Jabber: Theory@jabber.org
Kineticode. Setting knowledge in motion.[sm]


Re: [mp1] Alternative for CHECK

Posted by Stas Bekman <st...@stason.org>.
David Wheeler wrote:
> On Thursday, February 20, 2003, at 07:04  PM, Stas Bekman wrote:
> 
>> PerlChildInitHandler? e.g. used by Apache::DBI to pre-connect to the db.
> 
> 
> Yeah, but I was looking for something pre-fork. Anything come to mind?

startup.pl?

in 2.0 you have: PerlPostConfigHandler
http://perl.apache.org/docs/2.0/user/handlers/server.html#PerlPostConfigHandler


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: [mp1] Alternative for CHECK

Posted by David Wheeler <da...@kineticode.com>.
On Thursday, February 20, 2003, at 07:04  PM, Stas Bekman wrote:

> PerlChildInitHandler? e.g. used by Apache::DBI to pre-connect to the 
> db.

Yeah, but I was looking for something pre-fork. Anything come to mind?

Thanks,

David

-- 
David Wheeler                                     AIM: dwTheory
david@kineticode.com                              ICQ: 15726394
                                                Yahoo!: dew7e
                                                Jabber: Theory@jabber.org
Kineticode. Setting knowledge in motion.[sm]


Re: [mp1] Alternative for CHECK

Posted by Stas Bekman <st...@stason.org>.
David Wheeler wrote:
> Hi All,
> 
> I'm writing a module that will run in Apache and has important code that 
> needs to run after all modules have loaded but before Apache forks and 
> starts serving requests. Since mod_perl 1.x ignores CHECK and INIT 
> blocks, and BEGIN blocks run too early for what I'm doing, I was 
> wondering if there's a hook in the mod_perl API where I can run some 
> code just before before Apache forks and starts serving requests?
> 
> If you must know what I'm doing, I'm looking for stuff in the symbol table.

PerlChildInitHandler? e.g. used by Apache::DBI to pre-connect to the db.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com