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 Stas Bekman <st...@stason.org> on 2001/11/21 16:29:16 UTC

[patch] more robust startup + counting

Once in a while someone is running mod_perl on a slow machine and the
server won't start in the time given it to. And everytime we would extend
this time... Today I was running mod_perl tests on the slow notebook, and
it'd fail to start most of the time. So here is the usual patch that bumps
up the time (last time it was 6!=24 secs) to 60 secs, which should put the
end to this.

On the way, I've a little bit simplified logic and made a bit nicer user
experience, by showing the wait time. I know that before that it was
testing every 1, 2, 3, 4, ... secs. but I don't think ping is a heavy
operation for not to test every sec.

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.40
diff -u -r1.40 TestServer.pm
--- Apache-Test/lib/Apache/TestServer.pm	2001/10/22 06:15:36	1.40
+++ Apache-Test/lib/Apache/TestServer.pm	2001/11/21 15:07:50
@@ -417,7 +417,7 @@
     }

     while ($old_pid and $old_pid == $self->pid) {
-        warning "old pid file ($old_pid) still exists\n";
+        warning "old pid file ($old_pid) still exists";
         sleep 1;
     }

@@ -426,34 +426,26 @@
     $mpm = "($mpm MPM)" if $mpm;
     print "using $version $mpm\n";

-    my $tries = 6;
+    my $wait_secs = 60; # XXX: make a constant?

-    for (1..$tries) {
-        my $pid = $self->pid;
-        if ($pid) {
-            if($_ > 1) {
-                print "ok\n";
-            }
-        }
-        else {
-            if ($_ == 1) {
-                print "waiting for server to warm up...";
-            }
-            elsif ($_ > $tries) {
-                print "giving up\n";
-                last;
-            }
-            else {
-                print "...";
-            }
-            sleep $_;
-            next;
+    my $start_time = time;
+    my $preamble = "\rwaiting for server to start: ";
+    while (1) {
+        my $delta = time - $start_time;
+        print $preamble, sprintf "%02d:%02d", (gmtime $delta)[1,0];
+        sleep 1;
+        if ($self->pid) {
+            print $preamble, "ok (waited $delta secs)\n";
+            last;
+        }
+        elsif ($delta > $wait_secs) {
+            print $preamble, "giving up after $delta secs\n";
+            last;
         }
-        last;
     }

     if (my $pid = $self->pid) {
-        print "\nserver $self->{name} started\n";
+        print "server $self->{name} started\n";

         my $vh = $config->{vhosts};
         my $by_port = sub { $vh->{$a}->{port} <=> $vh->{$b}->{port} };
@@ -479,26 +471,24 @@
     if ($server_up->()) {
         return 1;
     }
-    else {
-        warning "still waiting for server to warm up...";
-        sleep 1;
-    }

-    for my $try (1..$tries) {
+    $start_time = time;
+    $preamble = "\rstill waiting for server to warm up: ";
+    while (1) {
+        my $delta = time - $start_time;
+        print $preamble, sprintf "%02d:%02d", (gmtime $delta)[1,0];
+        sleep 1;
         if ($server_up->()) {
-            print "ok\n";
-            return 1;
-        }
-        elsif ($try >= $tries) {
-            print "giving up\n";
+            print $preamble, "ok (waited $delta secs)\n";
+            last;
         }
-        else {
-            print "...";
-            sleep $try;
+        elsif ($delta > $wait_secs) {
+            print $preamble, "giving up after $delta secs\n";
+            last;
         }
     }

-    $self->failed_msg("\nfailed to start server!");
+    $self->failed_msg("failed to start server!");
     return 0;
 }




_____________________________________________________________________
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] more robust startup + counting

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

> On Wed, 5 Dec 2001, Stas Bekman wrote:
>  
> 
>>I suggest having an APACHE_TEST_CRON_MODE env var which will also 
>>replace APACHE_TEST_NO_COLOR. Sounds OK?
>>
> 
> i'd just rather have a different name.  this'll be useful for more than
> cron.  in fact i'd be happy to stick with APACHE_TEST_NO_COLOR.

so be it.


_____________________________________________________________________
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] more robust startup + counting

Posted by Doug MacEachern <do...@covalent.net>.
On Wed, 5 Dec 2001, Stas Bekman wrote:
 
> I suggest having an APACHE_TEST_CRON_MODE env var which will also 
> replace APACHE_TEST_NO_COLOR. Sounds OK?

i'd just rather have a different name.  this'll be useful for more than
cron.  in fact i'd be happy to stick with APACHE_TEST_NO_COLOR.


Re: [patch] more robust startup + counting

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

> one thing we need to "fix" with this new feature is the ability to turn
> off this output.  for the same reason we have $ENV{APACHE_TEST_NO_COLOR}
> to turn off the colors.  for when t/TEST output is redirected to a file,
> like from a cron job.  at the moment t/TEST > test.log outputs a bunch of 
> "waiting for server to start: 00:nn".  maybe have one ENV var to turn off
> all things like this, APACHE_TEST_SIMPLE_OUTPUT or something.

Yup, Philippe has already complained to me about this.

I suggest having an APACHE_TEST_CRON_MODE env var which will also 
replace APACHE_TEST_NO_COLOR. Sounds OK?




_____________________________________________________________________
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] more robust startup + counting

Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
Doug MacEachern wrote:
> 
> one thing we need to "fix" with this new feature is the ability to turn
> off this output.  for the same reason we have $ENV{APACHE_TEST_NO_COLOR}
> to turn off the colors.  for when t/TEST output is redirected to a file,
> like from a cron job.  at the moment t/TEST > test.log outputs a bunch of
> "waiting for server to start: 00:nn".  maybe have one ENV var to turn off
> all things like this, APACHE_TEST_SIMPLE_OUTPUT or something.

How about APACHE_TEST_BATCH_OUTPUT?
-- 
#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] more robust startup + counting

Posted by Doug MacEachern <do...@covalent.net>.
one thing we need to "fix" with this new feature is the ability to turn
off this output.  for the same reason we have $ENV{APACHE_TEST_NO_COLOR}
to turn off the colors.  for when t/TEST output is redirected to a file,
like from a cron job.  at the moment t/TEST > test.log outputs a bunch of 
"waiting for server to start: 00:nn".  maybe have one ENV var to turn off
all things like this, APACHE_TEST_SIMPLE_OUTPUT or something.




Re: [patch] more robust startup + counting

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

> this broke something.  i keep getting:
> 
> % t/TEST
> ...
> waiting for server to start: ok (waited 0 secs)
> ...
> still waiting for server to warm up: ok (waited 1 secs)
> failed to start server! (please examine t/logs/error_log)
> 
> and yet the server is running.


that's a bug. here is a fix (hope it's not mangled).


--- Apache-Test/lib/Apache/TestServer.pm        2001/11/22 03:13:04     1.41
+++ Apache-Test/lib/Apache/TestServer.pm        2001/11/29 07:26:21
@@ -480,7 +480,7 @@
          sleep 1;
          if ($server_up->()) {
              print $preamble, "ok (waited $delta secs)\n";
-            last;
+            return 1;
          }
          elsif ($delta > $wait_secs) {
              print $preamble, "giving up after $delta secs\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] more robust startup + counting

Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
Stas Bekman wrote:
> 
> And this problem still has nothing to do with the latest fix. Just for
> the kicks try to replace this version with 1.41 or 1.40 or TestServer.pm
> and you will see.

Sure enough.  Beats the crap out of me what happened.  It's
all better now.  Foo, I thought reg-tests were supposed to
be deterministic? :-D
-- 
#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] more robust startup + counting

Posted by Stas Bekman <st...@stason.org>.
Rodent of Unusual Size wrote:

 > Stas Bekman wrote:
 >
 >>Rodent of Unusual Size wrote:
 >>
 >> > Eh, I'm now getting this on Win32:
 >> >
 >> > perl t\TEST
 >> > apache.exe -v failed: Bad file descriptor at 
Apache-Test/lib/Apache/TestConfig.pm line 687.
 >>
 >>I don't think this has anything to do with this. If the line counter
 >>wasn't shifted, you've got a broken Symbol::gensym.
 >>
 >
 > I ran it this morning witk a checkout from a couple of days ago.
 > No worries.  I updated this morning and ran it again, with the
 > results above.  The only file changed by the update was
 >
 > perl-framework/Apache-Test/lib/Apache/TestServer.pm
 >
 > Nothing else has happened on my system; no Perl module
 > changes or anything.  Ergo, the change to the above file
 > is what broke my harness.
 >

And this problem still has nothing to do with the latest fix. Just for
the kicks try to replace this version with 1.41 or 1.40 or TestServer.pm
and you will see.

-- 


_____________________________________________________________________
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] more robust startup + counting

Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
Rodent of Unusual Size wrote:
> 
> Stas Bekman wrote:
> >
> > I don't think this has anything to do with this. If the line counter
> > wasn't shifted, you've got a broken Symbol::gensym.

The failing line is:

    open $handle, "$cmd|" or die "$cmd failed: $!";
-- 
#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] more robust startup + counting

Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
Stas Bekman wrote:
> 
> Rodent of Unusual Size wrote:
> 
>  > Eh, I'm now getting this on Win32:
>  >
>  > perl t\TEST
>  > apache.exe -v failed: Bad file descriptor at Apache-Test/lib/Apache/TestConfig.pm line 687.
> 
> I don't think this has anything to do with this. If the line counter
> wasn't shifted, you've got a broken Symbol::gensym.

I ran it this morning witk a checkout from a couple of days ago.
No worries.  I updated this morning and ran it again, with the
results above.  The only file changed by the update was

perl-framework/Apache-Test/lib/Apache/TestServer.pm

Nothing else has happened on my system; no Perl module
changes or anything.  Ergo, the change to the above file
is what broke my harness.
-- 
#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] more robust startup + counting

Posted by Stas Bekman <st...@stason.org>.
Rodent of Unusual Size wrote:

 > Stas Bekman wrote:
 >
 >>In this particular case it was a bug in my latest patch. It's fixed now.
 >>
 >
 > Eh, I'm now getting this on Win32:
 >
 > perl t\TEST
 > apache.exe -v failed: Bad file descriptor at 
Apache-Test/lib/Apache/TestConfig.pm line 687.


I don't think this has anything to do with this. If the line counter
wasn't shifted, you've got a broken Symbol::gensym.

686: Symbol::gensym();

_____________________________________________________________________
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] more robust startup + counting

Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
Stas Bekman wrote:
> 
> In this particular case it was a bug in my latest patch. It's fixed now.

Eh, I'm now getting this on Win32:

perl t\TEST
apache.exe -v failed: Bad file descriptor at Apache-Test/lib/Apache/TestConfig.pm line 687.

??
-- 
#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] more robust startup + counting

Posted by Stas Bekman <st...@stason.org>.
William A. Rowe, Jr. wrote:

> That would be my patch to detect an 'extra unused arg' to httpd.
> 
> As it is, there was no quick-fix I could see, so I've reverted.
> Update your httpd-2.0 cvs


In this particular case it was a bug in my latest patch. It's fixed now.


> ----- Original Message ----- 
> From: "Doug MacEachern" <do...@covalent.net>
> To: <te...@httpd.apache.org>
> Sent: Thursday, November 29, 2001 1:34 AM
> Subject: Re: [patch] more robust startup + counting
> 
> 
> 
>>this broke something.  i keep getting:
>>
>>% t/TEST
>>...
>>waiting for server to start: ok (waited 0 secs)
>>...
>>still waiting for server to warm up: ok (waited 1 secs)
>>failed to start server! (please examine t/logs/error_log)
>>
>>and yet the server is running.
>>
>>
>>
>>
>>



-- 


_____________________________________________________________________
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] more robust startup + counting

Posted by "William A. Rowe, Jr." <wr...@covalent.net>.
That would be my patch to detect an 'extra unused arg' to httpd.

As it is, there was no quick-fix I could see, so I've reverted.
Update your httpd-2.0 cvs


----- Original Message ----- 
From: "Doug MacEachern" <do...@covalent.net>
To: <te...@httpd.apache.org>
Sent: Thursday, November 29, 2001 1:34 AM
Subject: Re: [patch] more robust startup + counting


> this broke something.  i keep getting:
> 
> % t/TEST
> ...
> waiting for server to start: ok (waited 0 secs)
> ...
> still waiting for server to warm up: ok (waited 1 secs)
> failed to start server! (please examine t/logs/error_log)
> 
> and yet the server is running.
> 
> 
> 
> 


Re: [patch] more robust startup + counting

Posted by Doug MacEachern <do...@covalent.net>.
this broke something.  i keep getting:

% t/TEST
...
waiting for server to start: ok (waited 0 secs)
...
still waiting for server to warm up: ok (waited 1 secs)
failed to start server! (please examine t/logs/error_log)

and yet the server is running.




Re: [patch] more robust startup + counting

Posted by Doug MacEachern <do...@covalent.net>.
On Wed, 21 Nov 2001, Stas Bekman wrote:

> Once in a while someone is running mod_perl on a slow machine and the
> server won't start in the time given it to. And everytime we would extend
> this time... Today I was running mod_perl tests on the slow notebook, and
> it'd fail to start most of the time. So here is the usual patch that bumps
> up the time (last time it was 6!=24 secs) to 60 secs, which should put the
> end to this.

sounds good, +1

> On the way, I've a little bit simplified logic and made a bit nicer user
> experience, by showing the wait time. I know that before that it was
> testing every 1, 2, 3, 4, ... secs. but I don't think ping is a heavy
> operation for not to test every sec.

sounds fine too.