You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Perrin Harkins <ph...@gmail.com> on 2009/03/02 16:20:33 UTC
Re: get backtrace emailed when code dies running under
ModPerl::RegistryPrefork?
On Mon, Mar 2, 2009 at 9:54 AM, Matthew Lenz <ma...@nocturnal.org> wrote:
> According to the docs CGI::Carp doesn't function properly with
> fatalToBrowser under mod_perl 2.
I'm not sure if that's accurate or not, but setting a $SIG{__DIE__}
handler should work fine. BTW, I assume you mean stacktrace, not
backtrace, which is usually associated with core dumps.
- Perrin
Re: get backtrace emailed when code dies running under ModPerl::RegistryPrefork?
Posted by Michael Peters <mp...@plusthree.com>.
Adam Prime wrote:
> This was news to me, so i went to the docs. According to them, you have
> to explicitly enable this behavior. see:
>
> http://perl.apache.org/docs/2.0/api/Apache2/Log.html#C_Apache2__Const__LOG_TOCLIENT_
>
>
> Is that still accurate?
I don't know about mod_perl2, but I didn't have to do anything to have it
enabled under mod_perl1.
--
Michael Peters
Plus Three, LP
Re: get backtrace emailed when code dies running under ModPerl::RegistryPrefork?
Posted by Adam Prime <ad...@utoronto.ca>.
Michael Peters wrote:
>
> You don't even need to use a __DIE__ handler. mod_perl will place any
> runtime errors into $r->notes('error-notes'). I don't like my errors
> going to the browser (only really works if your content is HTML anyway)
> but for the email I usually use an Apache cleanup handler. That way it
> gets sent after the client request has returned, so they don't have to
> wait on it.
>
This was news to me, so i went to the docs. According to them, you have
to explicitly enable this behavior. see:
http://perl.apache.org/docs/2.0/api/Apache2/Log.html#C_Apache2__Const__LOG_TOCLIENT_
Is that still accurate?
Adam
Re: get backtrace emailed when code dies running under ModPerl::RegistryPrefork?
Posted by Michael Peters <mp...@plusthree.com>.
Perrin Harkins wrote:
> I'm not sure if that's accurate or not, but setting a $SIG{__DIE__}
> handler should work fine.
You don't even need to use a __DIE__ handler. mod_perl will place any runtime
errors into $r->notes('error-notes'). I don't like my errors going to the
browser (only really works if your content is HTML anyway) but for the email I
usually use an Apache cleanup handler. That way it gets sent after the client
request has returned, so they don't have to wait on it.
I use something like this:
# in httpd.conf where you need it
PerlCleanupHandler MyProject::ApacheCleanup
# in MyProject/ApacheCleanup.pm
package MyProject::ApacheCleanup;
use Apache::Constants qw(:common);
sub handler ($$) {
my ($class, $r) = @_;
return DECLINED unless $r->is_main;
my $status = $r->last->status;
return DECLINED unless $status == SERVER_ERROR;
my $error = $r->notes('error-notes') || $ENV{ERROR_NOTES};
return DECLINED unless $error;
# create your email message and send it. I also like to put in a
# Data::Dumper dump of %ENV, the URL, timestamp and other project
# specific config settings
return DECLINED;
}
--
Michael Peters
Plus Three, LP
Re: get backtrace emailed when code dies running under
ModPerl::RegistryPrefork?
Posted by Matthew Lenz <ma...@nocturnal.org>.
On Mon, 2009-03-02 at 10:20 -0500, Perrin Harkins wrote:
> On Mon, Mar 2, 2009 at 9:54 AM, Matthew Lenz <ma...@nocturnal.org> wrote:
> > According to the docs CGI::Carp doesn't function properly with
> > fatalToBrowser under mod_perl 2.
>
> I'm not sure if that's accurate or not, but setting a $SIG{__DIE__}
> handler should work fine.
Isn't that basically what fatalsToBrowser does? You'd think that the
CGI/Carp developer(s) would have been able to get it working with
mod_perl 2.
I can try it though. Will sticking the $SIG{__DIE__} in the startup.pl
script be sufficient?
> BTW, I assume you mean stacktrace, not
> backtrace, which is usually associated with core dumps.
HAHA, yes. I was just getting ready to correct myself :) Thanks for
beating me to it.
> - Perrin