mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Fixed execute function - now only displays output when there is an error.
This commit is contained in:
parent
7f4c4e13d2
commit
e36a785b1b
@ -68,8 +68,8 @@ sub BackRestTestBackup_ClusterCreate
|
||||
" --config=" . BackRestTestCommon_DbPathGet() . "/pg_backrest.conf archive-push %p";
|
||||
|
||||
BackRestTestCommon_Execute("initdb -D $strPath -A trust");
|
||||
BackRestTestCommon_Execute("/Library/PostgreSQL/9.3/bin/pg_ctl start -o \"-c port=$iPort -c checkpoint_segments=1 -c wal_level=archive " .
|
||||
"-c archive_mode=on -c archive_command='$strArchive'\" " .
|
||||
BackRestTestCommon_Execute("/Library/PostgreSQL/9.3/bin/pg_ctl start -o \"-c port=$iPort -c checkpoint_segments=1 " .
|
||||
"-c wal_level=archive -c archive_mode=on -c archive_command='$strArchive'\" " .
|
||||
"-D $strPath -l $strPath/postgresql.log -w -s");
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,14 @@ sub BackRestTestCommon_Execute
|
||||
}
|
||||
|
||||
my $strError;
|
||||
my $pId = open3(undef, undef, undef, $strCommand);
|
||||
my $hError;
|
||||
open($hError, '>', \$strError) or confess "unable to open handle to stderr string: $!\n";
|
||||
# #
|
||||
my $strOut;
|
||||
my $hOut;
|
||||
open($hOut, '>', \$strOut) or confess "unable to open handle to stdout string: $!\n";
|
||||
|
||||
my $pId = open3(undef, $hOut, $hError, $strCommand);
|
||||
|
||||
# Wait for the process to finish and report any errors
|
||||
waitpid($pId, 0);
|
||||
@ -72,9 +79,21 @@ sub BackRestTestCommon_Execute
|
||||
|
||||
if ($iExitStatus != 0 && !$bSuppressError)
|
||||
{
|
||||
confess &log(ERROR, "command '${strCommand}' returned " . $iExitStatus . ": " .
|
||||
(defined($strError) ? $strError : "[unknown]"));
|
||||
while (my $strLine = readline($hError))
|
||||
{
|
||||
print $strLine;
|
||||
}
|
||||
|
||||
confess &log(ERROR, "command '${strCommand}' returned " . $iExitStatus);
|
||||
}
|
||||
|
||||
close($hError);
|
||||
close($hOut);
|
||||
|
||||
# while (my $strLine = readline($hOut))
|
||||
# {
|
||||
# print $strLine;
|
||||
# }
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
|
Loading…
Reference in New Issue
Block a user