Implement timeout

This commit is contained in:
hjp 2021-01-21 15:34:30 +00:00
parent d79a7d083c
commit 34ce8eb0bc
4 changed files with 21 additions and 4 deletions

View File

@ -4,7 +4,7 @@
"unknown"
],
"dynamic_config" : 0,
"generated_by" : "Module::Build version 0.4224",
"generated_by" : "Module::Build version 0.4231",
"license" : [
"perl_5"
],
@ -50,5 +50,5 @@
]
},
"version" : "0.002",
"x_serialization_backend" : "JSON::PP version 2.97001"
"x_serialization_backend" : "JSON::PP version 4.02"
}

View File

@ -4,7 +4,7 @@ author:
- unknown
build_requires: {}
dynamic_config: 0
generated_by: 'Module::Build version 0.4224, CPAN::Meta::Converter version 2.150010'
generated_by: 'Module::Build version 0.4231, CPAN::Meta::Converter version 2.150010'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html

View File

@ -61,6 +61,7 @@ CREATE TABLE `filesets` (
`dir` text,
`options` text,
active tinyint not null default 1,
timeout int,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;

View File

@ -12,7 +12,7 @@ This class represents one instance of a running collecting agent.
The only user-callable methods are the constructor new and the instance
method run, which collects all the files from various disk agents.
The Simba::CA package is a hashref with the following keys:
The Simba::CA object is a hashref with the following keys:
=over
@ -30,6 +30,8 @@ The Simba::CA package is a hashref with the following keys:
=item targets
A list of entries (hashes) from table filesets.
=item ssh_id_file
=item target
@ -50,6 +52,10 @@ The Simba::CA package is a hashref with the following keys:
=item file_dfd
=item start_time
Timestamp when the backup of the current target started. Used to test when to abort due to timeout.
=back
=cut
@ -208,6 +214,7 @@ sub backup2disk {
$self->log(3, "starting backup for target host " . $target->{host} . " dir " . $target->{dir});
$self->{target} = $target;
$self->{start_time} = time();
# get previous generation
$self->get_last_session();
@ -226,6 +233,15 @@ sub backup2disk {
close($list_cfd);
my $count = 0;
while (<$list_dfd>) {
if ($target->{timeout}) {
my $now = time();
my $elapsed = $now - $self->{start_time};
$self->log(10, "checking timeout " . $elapsed . " > " . $target->{timeout});
if ($elapsed > $target->{timeout}) {
$self->log(3, "Timeout exceeded. $elapsed > $target->{timeout}");
last;
}
}
$count++;
chomp;
$self->log(10, "file: $_");