Mercurial > hg > nginx-tests
diff lib/Test/Nginx.pm @ 1206:c99c1f43cb15
Tests: reload() introduced in Test::Nginx.
This method replaces ad-hoc solutions to reload nginx, and adds win32 support.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 09 Aug 2017 15:57:38 +0300 |
parents | c0fa3f818103 |
children | a6453cf5786a |
line wrap: on
line diff
--- a/lib/Test/Nginx.pm +++ b/lib/Test/Nginx.pm @@ -421,6 +421,29 @@ sub waitforsocket($) { return undef; } +sub reload() { + my ($self) = @_; + + return $self unless $self->{_started}; + + my $pid = $self->read_file('nginx.pid'); + + if ($^O eq 'MSWin32') { + my $testdir = $self->{_testdir}; + my @globals = $self->{_test_globals} ? + () : ('-g', "pid $testdir/nginx.pid; " + . "error_log $testdir/error.log debug;"); + system($NGINX, '-p', $testdir, '-c', "nginx.conf", + '-s', 'reload', @globals) == 0 + or die "system() failed: $?\n"; + + } else { + kill 'HUP', $pid; + } + + return $self; +} + sub stop() { my ($self) = @_;