If you're developing web under modperl + Mason,maybe you should read 
the book of 'Practical mod_perl' written by Stas Bekman.Below pieces 
are coming from this book:

6.4.10 END Blocks
As the perlmod manpage explains, an END subroutine is executed when the 
Perl interpreter exits. In the mod_perl environment, the Perl 
interpreter exits only when the child process exits. Usually a single 
process serves many requests before it exits, so END blocks cannot be 
used if they are expected to do something at the end of each request's 
processing.

If there is a need to run some code after a request has been processed, 
the $r->register_cleanup( ) function should be used. This function 
accepts a reference to a function to be called during the 
PerlCleanupHandler phase, which behaves just like the END block in the 
normal Perl environment. For example:

$r->register_cleanup(sub { warn "$$ does cleanup\n" });
or:

sub cleanup { warn "$$ does cleanup\n" };
$r->register_cleanup(\&cleanup);
will run the registered code at the end of each request, similar to END 
blocks under mod_cgi.

As you already know by now, Apache::Registry handles things 
differently. It does execute all END blocks encountered during 
compilation of Apache::Registry scripts at the end of each request, 
like mod_cgi does. That includes any END blocks defined in the packages 
use( )d by the scripts.

If you want something to run only once in the parent process on 
shutdown and restart, you can use register_cleanup( ) in startup.pl:

warn "parent pid is $$\n";
Apache->server->register_cleanup(
    sub { warn "server cleanup in $$\n" });
This is useful when some server-wide cleanup should be performed when 
the server is stopped or restarted.


----
Yonghua (Jeff)
[EMAIL PROTECTED]
[EMAIL PROTECTED]

-----Original Message-----
From: [EMAIL PROTECTED]
To: mason-users@lists.sourceforge.net
Sent: Thu, 24 Aug 2006 6:51 AM
Subject: [Mason] Catching Apache Child Exit

What is the Mason-native equivalent of an END {} block? That is, how
can I trap the exiting of an apache child, and run my own code just
before it goes away?

Thanks.

    -- Patrick

--
.------ Patrick M. Jordan ------.  Random unused band name:
| Systems/Network Administrator |  DJ Massive Filesystem Corruption
`----- Antistatic Matrix -------'


-------------------------------------------------------------------------

Using Tomcat but need to do more? Need to support web services, 
security?
Get stuff done quickly with pre-integrated technology to make your job 
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache 
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

________________________________________________________________________
Check out AOL.com today. Breaking news, video search, pictures, email 
and IM. All on demand. Always Free.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to