mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
omnishell retries
This commit is contained in:
parent
84c6640032
commit
a5ab29e90e
@ -1731,28 +1731,48 @@ sub execute_command_timeout {
|
|||||||
# $std_files = ' >> /tmp/stdout 2>> /tmp/stderr
|
# $std_files = ' >> /tmp/stdout 2>> /tmp/stderr
|
||||||
################################################################################
|
################################################################################
|
||||||
sub execute_command_block {
|
sub execute_command_block {
|
||||||
my ($commands, $std_files, $timeout) = @_;
|
my ($commands, $std_files, $timeout, $retry) = @_;
|
||||||
|
|
||||||
return 0 unless defined($commands);
|
return 0 unless defined($commands);
|
||||||
|
|
||||||
|
my $retries = $retry;
|
||||||
|
|
||||||
|
$retries = 1 unless looks_like_number($retries) && $retries > 0;
|
||||||
|
|
||||||
my $err_level = 0;
|
my $err_level = 0;
|
||||||
$std_files = '' unless defined ($std_files);
|
$std_files = '' unless defined ($std_files);
|
||||||
|
|
||||||
if (ref($commands) ne "ARRAY") {
|
if (ref($commands) ne "ARRAY") {
|
||||||
return 0 if $commands eq '';
|
return 0 if $commands eq '';
|
||||||
$err_level = execute_command_timeout(
|
|
||||||
"($commands) $std_files",
|
do {
|
||||||
$timeout
|
$err_level = execute_command_timeout(
|
||||||
);
|
"($commands) $std_files",
|
||||||
|
$timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
# Do not retry if success.
|
||||||
|
last if looks_like_number($err_level) && $err_level == 0;
|
||||||
|
} while ((--$retries) > 0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
foreach my $comm (@{$commands}) {
|
foreach my $comm (@{$commands}) {
|
||||||
next unless defined($comm);
|
next unless defined($comm);
|
||||||
$err_level = execute_command_timeout(
|
$retries = $retry;
|
||||||
"($comm) $std_files",
|
$retries = 1 unless looks_like_number($retries) && $retries > 0;
|
||||||
$timeout
|
|
||||||
);
|
|
||||||
|
|
||||||
|
do {
|
||||||
|
$err_level = execute_command_timeout(
|
||||||
|
"($comm) $std_files",
|
||||||
|
$timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
# Do not retry if success.
|
||||||
|
last if looks_like_number($err_level) && $err_level == 0;
|
||||||
|
|
||||||
|
} while ((--$retries) > 0);
|
||||||
|
|
||||||
|
# Do not continue evaluating block if failed.
|
||||||
last unless ($err_level == 0);
|
last unless ($err_level == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user