>
> We have an an embperl application running on embperl 1.2b7, mod_perl
> 1.21, Apache 1.3.6 .  Its .epl files use an in-house Perl module called
> Axe.pm by calling
>     [! use Axe; !]
>
> This module's BEGIN block tries to connect to a database:
>   $Axe::Connection::dbh = DBI->connect(bunch of parameters) or
>     die('Axe::Connection cannot connect to Oracle!');
>
> Everything works most of the time.  Sometimes this DB connection fails
> in one of the Apache child processes.  But that Apache process continues
> to run despite the die().  Whenever the embperl application happens to
> run in that Apache instance, it has all kinds of problems because the
> required module didn't initialize successfully.
>
> 1.  How can I get the failure in the BEGIN module to kill that Apache
> process?  Calling die() and exit from embperl don't kill it.
>

You can try CORE::exit (), but this is really the hard way. Apache doesn't
have any chance to cleanup.

"die" in Embperl exits the current block, "exit" the current page

>
> 2.  I suspect there's a better way to do this, by loading the Axe module
> in Apache's startup.pl.  I believe the original developer tried that,
> and had problems because we wanted each child Apache process to have its
> own connection to the database.  Should I instead use the Apache::DBI
> wrapper as suggested in the mod_perl docs, or are there even better ways
> to do per-child initialization with embperl?
>

Normaly databases only works if you have a database connection per child. If
you want to make per child initialisation, you can use mod_perl's
PerlChildInitHandler. The other solutions, which I normaly use, is to always
connect to the database, but use Apache::DBI. Apache::DBI will keep track
that the connection is setup only the first time, further calls to connect
will simply get the already open database handle.

http://perl.apache.org/guide/databases.html may give you further ideas

Gerald



-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     [EMAIL PROTECTED]         Voice:    +49 6133 925151
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to