You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-dev@httpd.apache.org by Rodent of Unusual Size <Ke...@Golux.Com> on 2001/11/30 21:23:14 UTC
perl-framework: mod_dav but not mod_dav?
{sigh}
On a Win32 build, I included mod_dav. The DLL is where it is
supposed to be, and it's apparently getting loaded. So how
come I'm getting
Syntax error on line 302 of ...extra.conf:
Invalid command 'DAVLockDB', perhaps mis-spelled..
That's inside an <IfModule mod_dav.c>, so the module is *definitely*
loaded -- but the directive isn't found?? Am I missing something
incredibly basic here?
--
#ken P-)}
Ken Coar, Sanagendamgagwedweinini http://Golux.Com/coar/
Author, developer, opinionist http://Apache-Server.Com/
"All right everyone! Step away from the glowing hamburger!"
Re: [patch] catch server dies early (was Re: perl-framework: mod_dav
but not mod_dav?)
Posted by Doug MacEachern <do...@covalent.net>.
On Mon, 24 Dec 2001, Stas Bekman wrote:
> This one preserves the original value of SIGCHLD and uses SIGINT instead
> of 15 in kill().
SIGINT or SIGTERM ?? either way, go with 'kill SIGFOO => $$' so it'll be
easier to get rid of POSIX.pm in the near future.
Re: [patch] catch server dies early (was Re: perl-framework: mod_dav
but not mod_dav?)
Posted by Stas Bekman <st...@stason.org>.
On Mon, 24 Dec 2001, Stas Bekman wrote:
> On Tue, 4 Dec 2001, Doug MacEachern wrote:
>
> > On Wed, 5 Dec 2001, Stas Bekman wrote:
> >
> > > ok, but that catches only syntax errors. if we can catch the return
> > > status from system() we can catch all errors, causing the failure.
> >
> > that would be great.
>
> ok, here it is. Have no clue whether you can re-use this for win32.
prev patch was partially broken.
This one preserves the original value of SIGCHLD and uses SIGINT instead
of 15 in kill().
Index: Apache-Test/lib/Apache/TestServer.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestServer.pm,v
retrieving revision 1.46
diff -u -r1.46 TestServer.pm
--- Apache-Test/lib/Apache/TestServer.pm 2001/12/20 17:30:54 1.46
+++ Apache-Test/lib/Apache/TestServer.pm 2001/12/23 19:42:34
@@ -402,6 +402,9 @@
}
print "$cmd\n";
+ my $child_pid;
+ my $child_in_pipe;
+ my $old_sig;
if (Apache::TestConfig::WIN32) {
#make sure only 1 process is started for win32
@@ -418,7 +421,18 @@
$config->{win32obj} = $obj;
}
else {
- system "$cmd &";
+ require POSIX;
+ $old_sig = $SIG{CHLD};
+ $SIG{CHLD} = sub {
+ while ((my $child = waitpid(-1, POSIX::WNOHANG())) > 0) {
+ my $status = $? >> 8;
+ if ($status) {
+ $self->failed_msg("\nserver has died with status $status");
+ kill POSIX::SIGINT(), $$;
+ }
+ }
+ };
+ $child_pid = open $child_in_pipe, "|$cmd";
}
while ($old_pid and $old_pid == $self->pid) {
@@ -450,6 +464,10 @@
last;
}
}
+
+ # now that the server has started don't abort the test run if it
+ # dies
+ $SIG{CHLD} = $old_sig || 'DEFAULT';
if (my $pid = $self->pid) {
print "server $self->{name} started\n";
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:stas@stason.org http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: [patch] catch server dies early (was Re: perl-framework: mod_dav
but not mod_dav?)
Posted by Doug MacEachern <do...@covalent.net>.
On Mon, 24 Dec 2001, Stas Bekman wrote:
> ok, here it is. Have no clue whether you can re-use this for win32.
+1. i'm sure it can't be used for win32, but hopefully Win32::Process
does the right thing.
> hmm, probably I should use POSIX::SIGINT() instead of 15 in kill.
shame we have to pull in the POSIX.pm baggage just for WNOHANG. for kill,
you can just use the signame with the builtin: kill SIGTERM => $$
[patch] catch server dies early (was Re: perl-framework: mod_dav
but not mod_dav?)
Posted by Stas Bekman <st...@stason.org>.
On Tue, 4 Dec 2001, Doug MacEachern wrote:
> On Wed, 5 Dec 2001, Stas Bekman wrote:
>
> > ok, but that catches only syntax errors. if we can catch the return
> > status from system() we can catch all errors, causing the failure.
>
> that would be great.
ok, here it is. Have no clue whether you can re-use this for win32.
hmm, probably I should use POSIX::SIGINT() instead of 15 in kill.
Index: Apache-Test/lib/Apache/TestServer.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestServer.pm,v
retrieving revision 1.46
diff -u -r1.46 TestServer.pm
--- Apache-Test/lib/Apache/TestServer.pm 2001/12/20 17:30:54 1.46
+++ Apache-Test/lib/Apache/TestServer.pm 2001/12/23 19:05:48
@@ -402,6 +402,8 @@
}
print "$cmd\n";
+ my $child_pid;
+ my $child_in_pipe;
if (Apache::TestConfig::WIN32) {
#make sure only 1 process is started for win32
@@ -418,7 +420,17 @@
$config->{win32obj} = $obj;
}
else {
- system "$cmd &";
+ require POSIX;
+ $SIG{CHLD} = sub {
+ while ((my $child = waitpid(-1, POSIX::WNOHANG())) > 0) {
+ my $status = $? >> 8;
+ if ($status) {
+ $self->failed_msg("\nserver has died with status $status");
+ kill 15, $$;
+ }
+ }
+ };
+ $child_pid = open $child_in_pipe, "|$cmd";
}
while ($old_pid and $old_pid == $self->pid) {
@@ -450,6 +462,10 @@
last;
}
}
+
+ # now that the server has started don't abort the test run if it
+ # dies
+ $SIG{CHLD} = 'IGNORE';
if (my $pid = $self->pid) {
print "server $self->{name} started\n";
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:stas@stason.org http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: perl-framework: mod_dav but not mod_dav?
Posted by Doug MacEachern <do...@covalent.net>.
On Wed, 5 Dec 2001, Stas Bekman wrote:
> ok, but that catches only syntax errors. if we can catch the return
> status from system() we can catch all errors, causing the failure.
that would be great.
Re: perl-framework: mod_dav but not mod_dav?
Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:
> On Tue, 4 Dec 2001, Stas Bekman wrote:
>
>
>>Actually, we don't have to run -t to test for failure, since the normal
>>execution fails as well and for all cases (not only syntax errors). The
>>problem is that we run:
>>
>> system "command &";
>>
>
> we can run "$cmd -t|" before that and check if the output contains
> "Syntax OK" or not.
ok, but that catches only syntax errors. if we can catch the return
status from system() we can catch all errors, causing the failure.
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:stas@stason.org http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: perl-framework: mod_dav but not mod_dav?
Posted by Doug MacEachern <do...@covalent.net>.
On Tue, 4 Dec 2001, Stas Bekman wrote:
> Actually, we don't have to run -t to test for failure, since the normal
> execution fails as well and for all cases (not only syntax errors). The
> problem is that we run:
>
> system "command &";
we can run "$cmd -t|" before that and check if the output contains
"Syntax OK" or not.
Re: perl-framework: mod_dav but not mod_dav?
Posted by Stas Bekman <st...@stason.org>.
Rodent of Unusual Size wrote:
> Stas Bekman wrote:
>
>>Rodent of Unusual Size wrote:
>>
>>
>>>BTW, this caused t/TEST to keep trying to start the server
>>>for a minute. Maybe an 'httpd -t' should be done first
>>>and bail immediately on failure? It would short-circuit the
>>>minute of waiting when we can *tell* it's not going to
>>>start..
>>>
>>you cannot test with -t, e.g. if I say:
>>
>>PerlModule DoesntExist
>>
>>it'll say:
>>
>>% /home/stas/httpd/prefork/bin/httpd -t -d
>>/home/stas/apache.org/modperl-2.0/t -f
>>/home/stas/apache.org/modperl-2.0/t/conf/httpd.conf -DAPACHE2
>>-DPERL_USEITHREADS
>>Syntax OK
>>
>
> But 'PerlModule DoesntExist' isn't a *syntax* failure.
> It's a dependency failure detected at runtime. So -t
> won't catch everything, no -- but it *will* catch some.
that's right, I was thinking globally.
>>tell me how can we programmatically learn that the start-up
>>has failed, without waiting for the pid file to appear
>>
>
> For run-time dependency failures such as you cite above, there
> isn't any way (currently). However, if there's a startup
> failure we *can* detect, why not do so?
Are there any plans to add such a feature?
Actually, we don't have to run -t to test for failure, since the normal
execution fails as well and for all cases (not only syntax errors). The
problem is that we run:
system "command &";
so we cannot get the return status, after shell detaches the process. So
may be forking and running system() without & +detaching the process is
what we want. The childs can communicate to the parent its failure via
SIGCHLD, which will abort the server. Doug?
Also I'm not sure what happens with the winXX case.
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:stas@stason.org http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: perl-framework: mod_dav but not mod_dav?
Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
Stas Bekman wrote:
>
> Rodent of Unusual Size wrote:
>
> > BTW, this caused t/TEST to keep trying to start the server
> > for a minute. Maybe an 'httpd -t' should be done first
> > and bail immediately on failure? It would short-circuit the
> > minute of waiting when we can *tell* it's not going to
> > start..
>
> you cannot test with -t, e.g. if I say:
>
> PerlModule DoesntExist
>
> it'll say:
>
> % /home/stas/httpd/prefork/bin/httpd -t -d
> /home/stas/apache.org/modperl-2.0/t -f
> /home/stas/apache.org/modperl-2.0/t/conf/httpd.conf -DAPACHE2
> -DPERL_USEITHREADS
> Syntax OK
But 'PerlModule DoesntExist' isn't a *syntax* failure.
It's a dependency failure detected at runtime. So -t
won't catch everything, no -- but it *will* catch some.
> tell me how can we programmatically learn that the start-up
> has failed, without waiting for the pid file to appear
For run-time dependency failures such as you cite above, there
isn't any way (currently). However, if there's a startup
failure we *can* detect, why not do so?
--
#ken P-)}
Ken Coar, Sanagendamgagwedweinini http://Golux.Com/coar/
Author, developer, opinionist http://Apache-Server.Com/
"All right everyone! Step away from the glowing hamburger!"
Re: perl-framework: mod_dav but not mod_dav?
Posted by Stas Bekman <st...@stason.org>.
Rodent of Unusual Size wrote:
> Rodent of Unusual Size wrote:
>
>>Syntax error on line 302 of ...extra.conf:
>>Invalid command 'DAVLockDB', perhaps mis-spelled..
>>
>
> BTW, this caused t/TEST to keep trying to start the server
> for a minute. Maybe an 'httpd -t' should be done first
> and bail immediately on failure? It would short-circuit the
> minute of waiting when we can *tell* it's not going to
> start..
>
you cannot test with -t, e.g. if I say:
PerlModule DoesntExist
it'll say:
% /home/stas/httpd/prefork/bin/httpd -t -d
/home/stas/apache.org/modperl-2.0/t -f
/home/stas/apache.org/modperl-2.0/t/conf/httpd.conf -DAPACHE2
-DPERL_USEITHREADS
Syntax OK
tell me how can we programmatically learn that the start-up has failed,
without waiting for the pid file to appear and we will fix that. e.g.
could httpd create some status file, where it says the last thing it was
doing? e.g. starting, restarting, dying (config error), dying
(segfault), stopping. This file could be used by various watchdogs,
which currently can only tell whether the server is working or not.
With this new status file, they can tell much more about the server
status. e.g. I have a watchdog that will attempt to restart the server,
since it cannot ping the server, but it causes a double restart if I've
manually restarted the server and the ping test has happened before the
server went up. It will also falsely send alert email saying that the
server was down :(
Currently I always keep the error_log file open in another console via
tail -f and watch the output.
We could try to parse this file to look for errors reports [error], but
this is not easy, since your error_log file could accummulate a lot of
restarts with various errors, so I don't think this will really work.
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:stas@stason.org http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: perl-framework: mod_dav but not mod_dav?
Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
Rodent of Unusual Size wrote:
>
> Syntax error on line 302 of ...extra.conf:
> Invalid command 'DAVLockDB', perhaps mis-spelled..
BTW, this caused t/TEST to keep trying to start the server
for a minute. Maybe an 'httpd -t' should be done first
and bail immediately on failure? It would short-circuit the
minute of waiting when we can *tell* it's not going to
start..
--
#ken P-)}
Ken Coar, Sanagendamgagwedweinini http://Golux.Com/coar/
Author, developer, opinionist http://Apache-Server.Com/
"All right everyone! Step away from the glowing hamburger!"
Re: perl-framework: mod_dav but not mod_dav?
Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
Rodent of Unusual Size wrote:
>
> Syntax error on line 302 of ...extra.conf:
> Invalid command 'DAVLockDB', perhaps mis-spelled..
Duh, because I have mod_dav but not mod_dav_fs..
--
#ken P-)}
Ken Coar, Sanagendamgagwedweinini http://Golux.Com/coar/
Author, developer, opinionist http://Apache-Server.Com/
"All right everyone! Step away from the glowing hamburger!"