Add some message logging
This commit is contained in:
parent
d8387b418d
commit
1e35d95df8
27
tests/ftp.pm
27
tests/ftp.pm
@ -147,7 +147,7 @@ sub checkalivepidfile {
|
|||||||
# how many times a pid is repeated it will only be signalled once.
|
# how many times a pid is repeated it will only be signalled once.
|
||||||
#
|
#
|
||||||
sub signalpids {
|
sub signalpids {
|
||||||
my ($signal, $pids)=@_;
|
my ($signal, $pids, $verbose)=@_;
|
||||||
|
|
||||||
if((not defined $signal) || (not defined $pids)) {
|
if((not defined $signal) || (not defined $pids)) {
|
||||||
return;
|
return;
|
||||||
@ -155,6 +155,7 @@ sub signalpids {
|
|||||||
if($pids !~ /\s+/) {
|
if($pids !~ /\s+/) {
|
||||||
# avoid sorting if only one pid
|
# avoid sorting if only one pid
|
||||||
if(checkalivepid($pids) > 0) {
|
if(checkalivepid($pids) > 0) {
|
||||||
|
printf ("* pid $pids signalled ($signal)\n") if($verbose);
|
||||||
kill($signal, $pids);
|
kill($signal, $pids);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -166,6 +167,7 @@ sub signalpids {
|
|||||||
if($prev != $pid) {
|
if($prev != $pid) {
|
||||||
$prev = $pid;
|
$prev = $pid;
|
||||||
if(checkalivepid($pid) > 0) {
|
if(checkalivepid($pid) > 0) {
|
||||||
|
printf ("* pid $pid signalled ($signal)\n") if($verbose);
|
||||||
kill($signal, $pid);
|
kill($signal, $pid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,11 +182,11 @@ sub signalpids {
|
|||||||
# with that pid is actually alive.
|
# with that pid is actually alive.
|
||||||
#
|
#
|
||||||
sub signalpidfile {
|
sub signalpidfile {
|
||||||
my ($signal, $pidfile)=@_;
|
my ($signal, $pidfile, $verbose)=@_;
|
||||||
|
|
||||||
my $pid = pidfromfile($pidfile);
|
my $pid = pidfromfile($pidfile);
|
||||||
if($pid > 0) {
|
if($pid > 0) {
|
||||||
signalpids($signal, $pid);
|
signalpids($signal, $pid, $verbose);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,16 +259,16 @@ sub waitalivepidfile {
|
|||||||
# any of them in DEFAULT_TIMEOUT_STOP seconds then it returns 0.
|
# any of them in DEFAULT_TIMEOUT_STOP seconds then it returns 0.
|
||||||
#
|
#
|
||||||
sub stopprocess {
|
sub stopprocess {
|
||||||
my ($pids)=@_;
|
my ($pids, $verbose)=@_;
|
||||||
|
|
||||||
if(not defined $pids) {
|
if(not defined $pids) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
signalpids("KILL", $pids);
|
signalpids("KILL", $pids, $verbose);
|
||||||
if(waitdeadpid($pids, $ONE_HALF_STOP_TIMEOUT) == 0) {
|
if(waitdeadpid($pids, $ONE_HALF_STOP_TIMEOUT) == 0) {
|
||||||
signalpids("KILL", $pids);
|
signalpids("KILL", $pids, $verbose);
|
||||||
if(waitdeadpid($pids, $ONE_THIRD_STOP_TIMEOUT) == 0) {
|
if(waitdeadpid($pids, $ONE_THIRD_STOP_TIMEOUT) == 0) {
|
||||||
signalpids("KILL", $pids);
|
signalpids("KILL", $pids, $verbose);
|
||||||
if(waitdeadpid($pids, $ONE_SIXTH_STOP_TIMEOUT) == 0) {
|
if(waitdeadpid($pids, $ONE_SIXTH_STOP_TIMEOUT) == 0) {
|
||||||
return 0; # at least one pid is still alive !!!
|
return 0; # at least one pid is still alive !!!
|
||||||
}
|
}
|
||||||
@ -284,7 +286,7 @@ sub stopprocess {
|
|||||||
# returns 0.
|
# returns 0.
|
||||||
#
|
#
|
||||||
sub stopprocesspidfile {
|
sub stopprocesspidfile {
|
||||||
my ($pidfile)=@_;
|
my ($pidfile, $verbose)=@_;
|
||||||
|
|
||||||
if(not defined $pidfile) {
|
if(not defined $pidfile) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -292,7 +294,7 @@ sub stopprocesspidfile {
|
|||||||
my $ret = 1; # assume success stopping it
|
my $ret = 1; # assume success stopping it
|
||||||
my $pid = checkalivepidfile($pidfile);
|
my $pid = checkalivepidfile($pidfile);
|
||||||
if($pid > 0) {
|
if($pid > 0) {
|
||||||
$ret = stopprocess($pid);
|
$ret = stopprocess($pid, $verbose);
|
||||||
}
|
}
|
||||||
unlinkpidfiles($pidfile);
|
unlinkpidfiles($pidfile);
|
||||||
return $ret;
|
return $ret;
|
||||||
@ -306,7 +308,7 @@ sub stopprocesspidfile {
|
|||||||
# to stop it in DEFAULT_TIMEOUT_STOP seconds then it returns 0.
|
# to stop it in DEFAULT_TIMEOUT_STOP seconds then it returns 0.
|
||||||
#
|
#
|
||||||
sub ftpkillslave {
|
sub ftpkillslave {
|
||||||
my ($id, $ext)=@_;
|
my ($id, $ext, $verbose)=@_;
|
||||||
|
|
||||||
if(not defined $id) {
|
if(not defined $id) {
|
||||||
$id = "";
|
$id = "";
|
||||||
@ -326,7 +328,7 @@ sub ftpkillslave {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($pids) {
|
if($pids) {
|
||||||
$ret = stopprocess($pids);
|
$ret = stopprocess($pids, $verbose);
|
||||||
}
|
}
|
||||||
if($pidfiles) {
|
if($pidfiles) {
|
||||||
unlinkpidfiles($pidfiles);
|
unlinkpidfiles($pidfiles);
|
||||||
@ -342,6 +344,7 @@ sub ftpkillslave {
|
|||||||
# of them in DEFAULT_TIMEOUT_STOP seconds then returns 0.
|
# of them in DEFAULT_TIMEOUT_STOP seconds then returns 0.
|
||||||
#
|
#
|
||||||
sub ftpkillslaves {
|
sub ftpkillslaves {
|
||||||
|
my ($verbose)=@_;
|
||||||
|
|
||||||
my $ret = 1; # assume success stopping them
|
my $ret = 1; # assume success stopping them
|
||||||
my $pids = "";
|
my $pids = "";
|
||||||
@ -359,7 +362,7 @@ sub ftpkillslaves {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($pids) {
|
if($pids) {
|
||||||
$ret = stopprocess($pids);
|
$ret = stopprocess($pids, $verbose);
|
||||||
}
|
}
|
||||||
if($pidfiles) {
|
if($pidfiles) {
|
||||||
unlinkpidfiles($pidfiles);
|
unlinkpidfiles($pidfiles);
|
||||||
|
@ -114,7 +114,7 @@ do {
|
|||||||
sub catch_zap {
|
sub catch_zap {
|
||||||
my $signame = shift;
|
my $signame = shift;
|
||||||
print STDERR "ftpserver.pl received SIG$signame, exiting\n";
|
print STDERR "ftpserver.pl received SIG$signame, exiting\n";
|
||||||
ftpkillslaves();
|
ftpkillslave($ftpdnum, $ext, 1);
|
||||||
die "Somebody sent me a SIG$signame";
|
die "Somebody sent me a SIG$signame";
|
||||||
}
|
}
|
||||||
$SIG{INT} = \&catch_zap;
|
$SIG{INT} = \&catch_zap;
|
||||||
|
@ -440,6 +440,7 @@ sub stoptestserver {
|
|||||||
my $serverpids = "";
|
my $serverpids = "";
|
||||||
|
|
||||||
if($run{$serv}) {
|
if($run{$serv}) {
|
||||||
|
logmsg ("RUN: Stopping the $serv server...\n");
|
||||||
if($run{$serv}{'slavepidfiles'}) {
|
if($run{$serv}{'slavepidfiles'}) {
|
||||||
for $pidfile (split(" ", $run{$serv}{'slavepidfiles'})) {
|
for $pidfile (split(" ", $run{$serv}{'slavepidfiles'})) {
|
||||||
$pidfiles .= " $pidfile";
|
$pidfiles .= " $pidfile";
|
||||||
@ -450,29 +451,41 @@ sub stoptestserver {
|
|||||||
}
|
}
|
||||||
delete $run{$serv}{'slavepidfiles'};
|
delete $run{$serv}{'slavepidfiles'};
|
||||||
}
|
}
|
||||||
if($run{$serv}{'pidfile'}) {
|
|
||||||
$pidfile = $run{$serv}{'pidfile'};
|
|
||||||
$pidfiles .= " $pidfile";
|
|
||||||
$pid = checkalivepidfile($pidfile);
|
|
||||||
if($pid > 0) {
|
|
||||||
$serverpids .= " $pid";
|
|
||||||
}
|
|
||||||
delete $run{$serv}{'pidfile'};
|
|
||||||
}
|
|
||||||
if($run{$serv}{'pids'}) {
|
if($run{$serv}{'pids'}) {
|
||||||
$pid = $run{$serv}{'pids'};
|
$pid = $run{$serv}{'pids'};
|
||||||
$serverpids .= " $pid";
|
$serverpids .= " $pid";
|
||||||
delete $run{$serv}{'pids'};
|
delete $run{$serv}{'pids'};
|
||||||
}
|
}
|
||||||
|
if($run{$serv}{'pidfile'}) {
|
||||||
|
$pidfile = $run{$serv}{'pidfile'};
|
||||||
|
$pidfiles .= " $pidfile";
|
||||||
|
$pid = checkalivepidfile($pidfile);
|
||||||
|
if(($pid > 0) && ($serverpids !~ /\b$pid\b/)) {
|
||||||
|
$serverpids .= " $pid";
|
||||||
|
}
|
||||||
|
delete $run{$serv}{'pidfile'};
|
||||||
|
}
|
||||||
if($run{$serv}) {
|
if($run{$serv}) {
|
||||||
delete $run{$serv};
|
delete $run{$serv};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($slavepids) {
|
if($slavepids) {
|
||||||
$ret = stopprocess($slavepids);
|
logmsg ("* slave pid(s) $slavepids\n");
|
||||||
}
|
}
|
||||||
if($serverpids) {
|
if($serverpids) {
|
||||||
$ret = stopprocess($serverpids);
|
logmsg ("* server pid(s) $serverpids\n");
|
||||||
|
}
|
||||||
|
if($slavepids) {
|
||||||
|
$ret = stopprocess($slavepids, 1);
|
||||||
|
if($ret == 0) {
|
||||||
|
logmsg ("* slave process is still alive !!!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($serverpids) {
|
||||||
|
$ret = stopprocess($serverpids, 1);
|
||||||
|
if($ret == 0) {
|
||||||
|
logmsg ("* server process is still alive !!!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if($pidfiles) {
|
if($pidfiles) {
|
||||||
unlinkpidfiles($pidfiles);
|
unlinkpidfiles($pidfiles);
|
||||||
@ -1849,6 +1862,7 @@ sub stopalltestservers {
|
|||||||
|
|
||||||
for my $serv (keys %run) {
|
for my $serv (keys %run) {
|
||||||
if($run{$serv}) {
|
if($run{$serv}) {
|
||||||
|
logmsg ("RUN: Stopping the $serv server...\n");
|
||||||
if($run{$serv}{'slavepidfiles'}) {
|
if($run{$serv}{'slavepidfiles'}) {
|
||||||
for $pidfile (split(" ", $run{$serv}{'slavepidfiles'})) {
|
for $pidfile (split(" ", $run{$serv}{'slavepidfiles'})) {
|
||||||
$pidfiles .= " $pidfile";
|
$pidfiles .= " $pidfile";
|
||||||
@ -1859,30 +1873,42 @@ sub stopalltestservers {
|
|||||||
}
|
}
|
||||||
delete $run{$serv}{'slavepidfiles'};
|
delete $run{$serv}{'slavepidfiles'};
|
||||||
}
|
}
|
||||||
if($run{$serv}{'pidfile'}) {
|
|
||||||
$pidfile = $run{$serv}{'pidfile'};
|
|
||||||
$pidfiles .= " $pidfile";
|
|
||||||
$pid = checkalivepidfile($pidfile);
|
|
||||||
if($pid > 0) {
|
|
||||||
$serverpids .= " $pid";
|
|
||||||
}
|
|
||||||
delete $run{$serv}{'pidfile'};
|
|
||||||
}
|
|
||||||
if($run{$serv}{'pids'}) {
|
if($run{$serv}{'pids'}) {
|
||||||
$pid = $run{$serv}{'pids'};
|
$pid = $run{$serv}{'pids'};
|
||||||
$serverpids .= " $pid";
|
$serverpids .= " $pid";
|
||||||
delete $run{$serv}{'pids'};
|
delete $run{$serv}{'pids'};
|
||||||
}
|
}
|
||||||
|
if($run{$serv}{'pidfile'}) {
|
||||||
|
$pidfile = $run{$serv}{'pidfile'};
|
||||||
|
$pidfiles .= " $pidfile";
|
||||||
|
$pid = checkalivepidfile($pidfile);
|
||||||
|
if(($pid > 0) && ($serverpids !~ /\b$pid\b/)) {
|
||||||
|
$serverpids .= " $pid";
|
||||||
|
}
|
||||||
|
delete $run{$serv}{'pidfile'};
|
||||||
|
}
|
||||||
if($run{$serv}) {
|
if($run{$serv}) {
|
||||||
delete $run{$serv};
|
delete $run{$serv};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($slavepids) {
|
if($slavepids) {
|
||||||
$ret = stopprocess($slavepids);
|
logmsg ("* slave pid(s) $slavepids\n");
|
||||||
}
|
}
|
||||||
if($serverpids) {
|
if($serverpids) {
|
||||||
$ret = stopprocess($serverpids);
|
logmsg ("* server pid(s) $serverpids\n");
|
||||||
|
}
|
||||||
|
if($slavepids) {
|
||||||
|
$ret = stopprocess($slavepids, 1);
|
||||||
|
if($ret == 0) {
|
||||||
|
logmsg ("* slave process is still alive !!!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($serverpids) {
|
||||||
|
$ret = stopprocess($serverpids, 1);
|
||||||
|
if($ret == 0) {
|
||||||
|
logmsg ("* server process is still alive !!!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if($pidfiles) {
|
if($pidfiles) {
|
||||||
unlinkpidfiles($pidfiles);
|
unlinkpidfiles($pidfiles);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user