Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

Quiet Internal Server Errors

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


jnarins at seniorbridge

Apr 4, 2012, 7:42 AM

Post #1 of 9 (935 views)
Permalink
Quiet Internal Server Errors

I'm porting a large mod_perl1 application to mod_perl2.

The server is now starting.

If I mistype some server configuration, it gives me errors, so I know the configuration is being read.

I tried adding this:

PerlModule Phase::PostConfig
PerlPostConfigHandler Phase::PostConfig::handler

and putting in the very simple:

use Apache2::Const -compile => 'OK';

sub post_config {
print STDERR "configuration is complete\n";
return Apache2::Const::OK;
}
1;

I see a hit in the access logs.

I get an Internal Server Error.

And still, the error log is completely silent. This is my problem. Without server errors I get a bit lost.

When I had a typo in a module, the error log would have stuff in it, so I don't think it is writing to an unexpected location for this.

I doubt it will help, but here is what is in the error log from start up.

[Wed Apr 04 10:36:13 2012] [info] Init: Seeding PRNG with 0 bytes of entropy
[Wed Apr 04 10:36:13 2012] [info] Init: Generating temporary RSA private keys (512/1024 bits)
[Wed Apr 04 10:36:13 2012] [info] Init: Generating temporary DH parameters (512/1024 bits)
[Wed Apr 04 10:36:13 2012] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Wed Apr 04 10:36:13 2012] [info] Init: Initializing (virtual) servers for SSL
[Wed Apr 04 10:36:13 2012] [info] mod_ssl/2.2.22 compiled against Server: Apache/2.2.22, Library: OpenSSL/1.0.0g
[Wed Apr 04 10:36:14 2012] [info] Init: Seeding PRNG with 0 bytes of entropy
[Wed Apr 04 10:36:14 2012] [info] Init: Generating temporary RSA private keys (512/1024 bits)
[Wed Apr 04 10:36:14 2012] [info] Init: Generating temporary DH parameters (512/1024 bits)
[Wed Apr 04 10:36:14 2012] [info] Init: Initializing (virtual) servers for SSL
[Wed Apr 04 10:36:14 2012] [info] mod_ssl/2.2.22 compiled against Server: Apache/2.2.22, Library: OpenSSL/1.0.0g
[Wed Apr 04 10:36:14 2012] [notice] Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0g mod_perl/2.0.5 Perl/v5.14.2 configured -- resuming normal operations
[Wed Apr 04 10:36:14 2012] [info] Server built: Mar 7 2012 17:23:30
[Wed Apr 04 10:36:14 2012] [debug] prefork.c(1023): AcceptMutex: sysvsem (default: sysvsem)



Josh Narins
Director of Application Development
SeniorBridge

845 Third Ave
7th Floor
New York, NY 10022
Tel: (212) 994-6194
Fax: (212) 994-4260
Mobile: (917) 488-6248
jnarins [at] seniorbridge
seniorbridge.com<http://www.seniorbridge.com/>

[http://www.seniorbridge.com/images/seniorbridgedisclaimerTAG.gif]


________________________________
SeniorBridge Statement of Confidentiality: The contents of this email message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. Any dissemination, distribution or copying of this email by an unintended or mistaken recipient is strictly prohibited. In said event, kindly reply to the sender and destroy all entries of this message and any attachments from your system. Thank you.


aw at ice-sa

Apr 4, 2012, 8:19 AM

Post #2 of 9 (864 views)
Permalink
Re: Quiet Internal Server Errors [In reply to]

Josh Narins wrote:
...

>
> I see a hit in the access logs.
>
> I get an Internal Server Error.
>
> And still, the error log is completely silent. This is my problem. Without server errors I get a bit lost.
>

This seems to be a config with VirtualHosts.
Are you sure that you're looking in the correct error logs ?
Some errors will be in the "main" log, others in the virtual host logs.
Also, "print STDERR" is not necessarily the best way to send an error to the logs, under
mod_perl 2.


torsten.foertsch at gmx

Apr 4, 2012, 8:34 AM

Post #3 of 9 (859 views)
Permalink
Re: Quiet Internal Server Errors [In reply to]

On Wednesday, 04 April 2012 10:42:47 Josh Narins wrote:
> PerlModule Phase::PostConfig
> PerlPostConfigHandler Phase::PostConfig::handler
>
> and putting in the very simple:
>
> use Apache2::Const -compile => 'OK';
>
> sub post_config {
> print STDERR "configuration is complete\n";
> return Apache2::Const::OK;
> }
> 1;

And you expect &post_config to act as PerlPostConfigHandler?

I think it should read either

package Phase::PostConfig;
...
sub handler {...}

or

sub Phase::PostConfig::handler {...}


Also, if the handler is named "handler" you may omit "::handler" in the
PerlPostConfigHandler argument:

PerlPostConfigHandler Phase::PostConfig

If your handler has any other name you must specify it:

PerlPostConfigHandler Phase::PostConfig::post_config


The combination you have chosen, naming the handler
Phase::PostConfig::post_config and configuring it as
Phase::PostConfig::handler won't work.

Torsten Förtsch

--
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net


jnarins at seniorbridge

Apr 4, 2012, 8:42 AM

Post #4 of 9 (863 views)
Permalink
RE: Quiet Internal Server Errors [In reply to]

> > I see a hit in the access logs.
> >
> > I get an Internal Server Error.
> >
> > And still, the error log is completely silent. This is my problem.
> Without server errors I get a bit lost.
> >
>
> This seems to be a config with VirtualHosts.
> Are you sure that you're looking in the correct error logs ?
> Some errors will be in the "main" log, others in the virtual host logs.
> Also, "print STDERR" is not necessarily the best way to send an error
> to the logs, under
> mod_perl 2.

While I am using Virtual Hosts, the PerlPostConfigHandler is defined outside any of them.

On a positive note, when I change from "print STDERR" to open my $fh, ">>/tmp/abc" in my PostConfig handler, the file is written.

I checked the whole machine, there are no other error logs. Do I need to set up virtual host error logs separately, and they just go to /dev/null without such configuration?



Josh Narins
Director of Application Development
SeniorBridge

845 Third Ave
7th Floor
New York, NY 10022
Tel: (212) 994-6194
Mobile: (917) 488-6248
Fax: (212) 994-4260
jnarins [at] seniorbridge

SeniorBridge
Managing Complex Chronic Care
http://www.seniorbridge.com



SeniorBridge Statement of Confidentiality: The contents of this email message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. Any dissemination, distribution or copying of this email by an unintended or mistaken recipient is strictly prohibited. In said event, kindly reply to the sender and destroy all entries of this message and any attachments from your system. Thank you.


jnarins at seniorbridge

Apr 4, 2012, 8:43 AM

Post #5 of 9 (854 views)
Permalink
RE: Quiet Internal Server Errors [In reply to]

>

Josh Narins
Director of Application Development
SeniorBridge

845 Third Ave
7th Floor
New York, NY 10022
Tel: (212) 994-6194
Mobile: (917) 488-6248
Fax: (212) 994-4260
jnarins [at] seniorbridge

SeniorBridge
Managing Complex Chronic Care
http://www.seniorbridge.com


SeniorBridge Statement of Confidentiality: The contents of this email message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. Any dissemination, distribution or copying of this email by an unintended or mistaken recipient is strictly prohibited. In said event, kindly reply to the sender and destroy all entries of this message and any attachments from your system. Thank you.-----Original Message-----
> From: Torsten Förtsch [mailto:torsten.foertsch [at] gmx]
> Sent: Wednesday, April 04, 2012 11:35 AM
> To: modperl [at] perl
> Cc: Josh Narins
> Subject: Re: Quiet Internal Server Errors
>
> On Wednesday, 04 April 2012 10:42:47 Josh Narins wrote:
> > PerlModule Phase::PostConfig
> > PerlPostConfigHandler Phase::PostConfig::handler
> >
> > and putting in the very simple:
> >
> > use Apache2::Const -compile => 'OK';
> >
> > sub post_config {
> > print STDERR "configuration is complete\n";
> > return Apache2::Const::OK;
> > }
> > 1;
>
> And you expect &post_config to act as PerlPostConfigHandler?
>
> I think it should read either
>
> package Phase::PostConfig;
> ...
> sub handler {...}
>
> or
>
> sub Phase::PostConfig::handler {...}
>
>
> Also, if the handler is named "handler" you may omit "::handler" in the
> PerlPostConfigHandler argument:
>
> PerlPostConfigHandler Phase::PostConfig
>
> If your handler has any other name you must specify it:
>
> PerlPostConfigHandler Phase::PostConfig::post_config
>
>
> The combination you have chosen, naming the handler
> Phase::PostConfig::post_config and configuring it as
> Phase::PostConfig::handler won't work.
>
> Torsten Förtsch

Sorry, that was just a typo in the message I sent. I have the subroutine named correctly on disk.


aw at ice-sa

Apr 4, 2012, 8:53 AM

Post #6 of 9 (854 views)
Permalink
Re: Quiet Internal Server Errors [In reply to]

Josh Narins wrote:
>>> I see a hit in the access logs.
>>>
>>> I get an Internal Server Error.
>>>
>>> And still, the error log is completely silent. This is my problem.
>> Without server errors I get a bit lost.
>> This seems to be a config with VirtualHosts.
>> Are you sure that you're looking in the correct error logs ?
>> Some errors will be in the "main" log, others in the virtual host logs.
>> Also, "print STDERR" is not necessarily the best way to send an error
>> to the logs, under
>> mod_perl 2.
>
> While I am using Virtual Hosts, the PerlPostConfigHandler is defined outside any of them.
>
> On a positive note, when I change from "print STDERR" to open my $fh, ">>/tmp/abc" in my PostConfig handler, the file is written.
>
> I checked the whole machine, there are no other error logs. Do I need to set up virtual host error logs separately, and they just go to /dev/null without such configuration?
>
Separately from Torsten's answers, as an appendix.

No, they will not just be discarded to /dev/null.

The "main" part of the configuration (outside of <VirtualHost> sections), acts as a series
of default values, inherited by all VirtualHosts. A <VirtualHost> /may/ override any
parameter with its own value, which takes precedence. But it does not have to.

Error messages may end up in the system's SYSLOG logs, depending on how the Apache startup
script of your system configures things (like in /etc/init.d/apache2 or so). The
imagination of Linux package creators is boundless..
Check /var/log/daemon.log and similar.


torsten.foertsch at gmx

Apr 4, 2012, 9:19 AM

Post #7 of 9 (852 views)
Permalink
Re: Quiet Internal Server Errors [In reply to]

On Wednesday, 04 April 2012 11:42:55 Josh Narins wrote:
> print STDERR

I don't use "print STDERR" much. So, I am not sure if you have to set $|=1 for
the handle. What happens if you replace "print STDERR" by "warn"? The
postconfig phase comes after openlogs. So, STDERR should point to the main
server errorlog.

Torsten Förtsch

--
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net


jnarins at seniorbridge

Apr 4, 2012, 9:24 AM

Post #8 of 9 (858 views)
Permalink
RE: Quiet Internal Server Errors [In reply to]

>>>> I see a hit in the access logs.
>>>>
>>>> I get an Internal Server Error.
>>>>
>>>> And still, the error log is completely silent. This is my problem.
>>>>
>>>> Without server errors I get a bit lost.
>>>>
>>> This seems to be a config with VirtualHosts.
>>> Are you sure that you're looking in the correct error logs ?
>>> Some errors will be in the "main" log, others in the virtual
>>> host logs.
>>> Also, "print STDERR" is not necessarily the best way to send
>>> an error to the logs, under mod_perl 2.
>>
>> While I am using Virtual Hosts, the PerlPostConfigHandler is defined
>> outside any of them.
>>
>> On a positive note, when I change from "print STDERR" to open my $fh,
>> ">>/tmp/abc" in my PostConfig handler, the file is written.
>>
>> I checked the whole machine, there are no other error logs. Do I need
>> to set up virtual host error logs separately, and they just go to
>> /dev/null without such configuration?
>>
> Separately from Torsten's answers, as an appendix.
>
> No, they will not just be discarded to /dev/null.
>
> The "main" part of the configuration (outside of <VirtualHost>
> sections), acts as a series of default values, inherited by
> all VirtualHosts. A <VirtualHost> /may/ override any
> parameter with its own value, which takes precedence. But it
> does not have to.

Thanks.

> Error messages may end up in the system's SYSLOG logs, depending on how
> the Apache startup script of your system configures things (like in
> /etc/init.d/apache2 or so). The imagination of Linux package creators
> is boundless..
> Check /var/log/daemon.log and similar.

I've built this all from source. That's the way I've been using
Apache/mod_perl for a long time now.

There's nothing happening under /var/log. I even tried this, as root:

> cd /
> touch STAMP
[ Try to load page and get internal server error ]
> find . -newer STAMP 2>/dev/null | egrep -v "^./(proc|sys|dev)/"
./home/mp2/builds/httpd/httpd-2.2.22/logs/access_log-dev9
./home/mp2/builds/httpd/httpd-2.2.22/logs/clickstream
./var/spool/postfix/public/qmgr
./var/spool/postfix/public/pickup

Now that I know PostConfig is working, I made a nearly identical
PostReadRequestHandler, the only difference being it writes to a
different /tmp file.

I also put its config in server scope, rather than in any Directory,
Location or Files section.

It does not get called.

So, I tried a ChildInitHandler.

Surely that would need to be called, right?

It does not.

I don't know if it will do any good, but here's the last of the
strace output from the parent process before it exits and leaves
1 root process and two (the correct number) of apache children
running as "web" (the correct user), around.

stat("/home/jnarins/src/dev9/etc/httpd/httpd.conf", {st_mode=S_IFREG|0644, st_size=3923, ...}) = 0
open("/home/jnarins/src/dev9/etc/httpd/httpd.conf", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=3923, ...}) = 0
read(5, "# $Id: httpd.conf 10123 2011-10-"..., 4096) = 3923
open("/home/mp2/builds/httpd/httpd-2.2.22/modules/mod_perl.so", O_RDONLY) = 6
read(6, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\361\3\0\0\0\0\0"..., 832) = 832
fstat(6, {st_mode=S_IFREG|0775, st_size=1847927, ...}) = 0
mmap(NULL, 3811048, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 6, 0) = 0x2ad4d464d000
mprotect(0x2ad4d47e5000, 2093056, PROT_NONE) = 0
mmap(0x2ad4d49e4000, 49152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 6, 0x197000) = 0x2ad4d49e4000
close(6) = 0
open("/home/mp2/builds/apr-util/apr-util-1.4.1/lib/libnsl.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/tls/libnsl.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/libnsl.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/mp2/builds/apr/apr-1.4.6/lib/libnsl.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=66554, ...}) = 0
mmap(NULL, 66554, PROT_READ, MAP_PRIVATE, 6, 0) = 0x2ad4d49f0000
close(6) = 0
open("/lib64/libnsl.so.1", O_RDONLY) = 6
read(6, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240@@,=\0\0\0"..., 832) = 832
fstat(6, {st_mode=S_IFREG|0755, st_size=114352, ...}) = 0
mmap(0x3d2c400000, 2194096, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 6, 0) = 0x3d2c400000
mprotect(0x3d2c415000, 2093056, PROT_NONE) = 0
mmap(0x3d2c614000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 6, 0x14000) = 0x3d2c614000
mmap(0x3d2c616000, 6832, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3d2c616000
close(6) = 0
open("/home/mp2/builds/apr-util/apr-util-1.4.1/lib/libutil.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/tls/libutil.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/libutil.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/mp2/builds/apr/apr-1.4.6/lib/libutil.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/libutil.so.1", O_RDONLY) = 6
read(6, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200\16\3408=\0\0\0"..., 832) = 832
fstat(6, {st_mode=S_IFREG|0755, st_size=18152, ...}) = 0
mmap(0x3d38e00000, 2105616, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 6, 0) = 0x3d38e00000
mprotect(0x3d38e02000, 2093056, PROT_NONE) = 0
mmap(0x3d39001000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 6, 0x1000) = 0x3d39001000
close(6) = 0
mprotect(0x3d39001000, 4096, PROT_READ) = 0
mprotect(0x3d2c614000, 4096, PROT_READ) = 0
munmap(0x2ad4d49f0000, 66554) = 0
read(5, "", 4096) = 0
close(5) = 0
chdir("/") = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x2ad4d464bd20) = 9011
exit_group(0) = ?


Josh Narins
Director of Application Development
SeniorBridge

845 Third Ave
7th Floor
New York, NY 10022
Tel: (212) 994-6194
Mobile: (917) 488-6248
Fax: (212) 994-4260
jnarins [at] seniorbridge

SeniorBridge
Managing Complex Chronic Care
http://www.seniorbridge.com



SeniorBridge Statement of Confidentiality: The contents of this email message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. Any dissemination, distribution or copying of this email by an unintended or mistaken recipient is strictly prohibited. In said event, kindly reply to the sender and destroy all entries of this message and any attachments from your system. Thank you.


jnarins at seniorbridge

Apr 4, 2012, 9:33 AM

Post #9 of 9 (863 views)
Permalink
RE: Quiet Internal Server Errors [In reply to]

> > print STDERR
>
> I don't use "print STDERR" much. So, I am not sure if you have to set
> $|=1 for
> the handle. What happens if you replace "print STDERR" by "warn"? The
> postconfig phase comes after openlogs. So, STDERR should point to the
> main
> server errorlog.

For now, to avoid any such issues, I am writing to files under /tmp,
a different once for each phase. For OpenLogs, PostConfig and
ChildInit, I am fine.

For PostReadRequest, I get nothing.

They are configured as follows:

PerlPostReadRequestHandler Rosalind::Phase::PostReadRequest
PerlOpenLogsHandler Rosalind::Phase::OpenLogs
PerlPostConfigHandler Rosalind::Phase::PostConfig
PerlChildInitHandler Rosalind::Phase::ChildInit

And the PostReadRequest handler, with perms 644, is as follows:

package Rosalind::Phase::PostReadRequest;

use Apache2::Const -compile => 'OK';

sub handler {
open my $fh,">>/tmp/PostReadRequest" or die "Nope: $!";
print $fh "pid: $$\n";
close $fh;
return Apache2::Const::OK;
}

1;


Josh Narins
Director of Application Development
SeniorBridge

845 Third Ave
7th Floor
New York, NY 10022
Tel: (212) 994-6194
Mobile: (917) 488-6248
Fax: (212) 994-4260
jnarins [at] seniorbridge

SeniorBridge
Managing Complex Chronic Care
http://www.seniorbridge.com



SeniorBridge Statement of Confidentiality: The contents of this email message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. Any dissemination, distribution or copying of this email by an unintended or mistaken recipient is strictly prohibited. In said event, kindly reply to the sender and destroy all entries of this message and any attachments from your system. Thank you.

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.