Mercurial > hg > nginx-tests
comparison lib/Test/Nginx.pm @ 1677:f13ead27f89c
Tests: improved stop() to send TERM after QUIT.
It is possible that graceful stop as initiated by SIGQUIT will take
very long time, such as when waiting for proxy_timeout in mail proxy
(defaults to 24h). To make sure in such cases nginx is stopped after
some reasonable time, we now send SIGTERM after waiting for 90 seconds.
Note that win32 version previously used "-s stop", which is equivalent
to SIGTERM rather than SIGQUIT. This seems accidental error during
introduction of initial win32 support in tests (ce2e23daa1da), so
it is changed to follow the same logic.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 19 May 2021 04:32:55 +0300 |
parents | 12f32d82936d |
children | ba6e24e38f03 |
comparison
equal
deleted
inserted
replaced
1676:816d6ceefe50 | 1677:f13ead27f89c |
---|---|
507 () : ('-g', "pid $testdir/nginx.pid; " | 507 () : ('-g', "pid $testdir/nginx.pid; " |
508 . "error_log $testdir/error.log debug;"); | 508 . "error_log $testdir/error.log debug;"); |
509 my @error = $self->has_version('1.19.5') ? | 509 my @error = $self->has_version('1.19.5') ? |
510 ('-e', 'error.log') : (); | 510 ('-e', 'error.log') : (); |
511 system($NGINX, '-p', $testdir, '-c', "nginx.conf", | 511 system($NGINX, '-p', $testdir, '-c', "nginx.conf", |
512 '-s', 'stop', @error, @globals) == 0 | 512 '-s', 'quit', @error, @globals) == 0 |
513 or die "system() failed: $?\n"; | 513 or die "system() failed: $?\n"; |
514 | 514 |
515 } else { | 515 } else { |
516 kill 'QUIT', $pid; | 516 kill 'QUIT', $pid; |
517 } | 517 } |
518 | 518 |
519 waitpid($pid, 0); | 519 my $exited; |
520 | |
521 for (1 .. 900) { | |
522 $exited = waitpid($pid, WNOHANG) != 0; | |
523 last if $exited; | |
524 select undef, undef, undef, 0.1; | |
525 } | |
526 | |
527 if (!$exited) { | |
528 if ($^O eq 'MSWin32') { | |
529 my $testdir = $self->{_testdir}; | |
530 my @globals = $self->{_test_globals} ? | |
531 () : ('-g', "pid $testdir/nginx.pid; " | |
532 . "error_log $testdir/error.log debug;"); | |
533 my @error = $self->has_version('1.19.5') ? | |
534 ('-e', 'error.log') : (); | |
535 system($NGINX, '-p', $testdir, '-c', "nginx.conf", | |
536 '-s', 'stop', @error, @globals) == 0 | |
537 or die "system() failed: $?\n"; | |
538 | |
539 } else { | |
540 kill 'TERM', $pid; | |
541 } | |
542 | |
543 waitpid($pid, 0); | |
544 } | |
520 | 545 |
521 $self->{_started} = 0; | 546 $self->{_started} = 0; |
522 | 547 |
523 return $self; | 548 return $self; |
524 } | 549 } |