Practical mod_perl / HTML Book /



previous page: 25.2.1.2. PerlPostConfigHandler
  
page up: HTML Version of the book
  
next page: 25.2.1.4. PerlChildExitHandler

25.2.1.3. PerlChildInitHandler


The child_init phase happens immediately after a child process is spawned. Each child process (not a thread!) will run the hooks of this phase only once in its life-time.

In the prefork MPM this phase is useful for initializing any data structures that should be private to each process. For example, Apache::DBI preopens database connections during this phase, and Apache::Resourcesets the process's resource limits.

The PerlChildInitHandler directive should appear in the top-level server configuration file. All PerlChildInitHandlers will be executed, disregarding their return values (although mod_perl expects a return value, so returning Apache::OK is a good idea).

In the Book::StartupLog example we used the child_init( ) handler:

sub child_init {
    my($child_pool, $s) = @_;
    say("process $$ is born to serve");
    return Apache::OK;
}

The child_init( ) handler accepts two arguments: the child process pool and the server object. The example handler logs the PID of the child process in which it's run and returns.

This handler is configured by adding the following to httpd.conf:

PerlChildInitHandler Book::StartupLog::child_init

 

Continue to:

  • prev: 25.2.1.2. PerlPostConfigHandler
  • Table of Contents
  • next: 25.2.1.4. PerlChildExitHandler







TOP
previous page: 25.2.1.2. PerlPostConfigHandler
  
page up: HTML Version of the book
  
next page: 25.2.1.4. PerlChildExitHandler


Menu

  • HTML Book
  • PDF Book
  • Download Code
  • Table of Contents
  • Errata
  • mod_perl2 User's Guide
  • Sitemap

Search


Add to Google




Creative Commons License


Written by
Eric Cholet (Logilune) and
Stas Bekman (StasoSphere & Free Books).


[ Privacy Policy | Terms of Use | About Us | Search ]

© 2007 StasoSphere.com