#228 timeout setting (default 10min) for backend jobs
This commit is contained in:
5
Build.PL
5
Build.PL
@@ -64,7 +64,8 @@ Module::Build->new(
|
||||
'Sereal' => '0',
|
||||
'Socket6' => '0.23',
|
||||
'Starman' => '0.4008',
|
||||
'Storable' => 0,
|
||||
'Storable' => '0',
|
||||
'Sys::SigAction' => '0',
|
||||
'SNMP::Info' => '3.40',
|
||||
'SQL::Translator' => '0.11018',
|
||||
'Template' => '2.24',
|
||||
@@ -75,7 +76,7 @@ Module::Build->new(
|
||||
'Try::Tiny' => '0',
|
||||
'URI' => '0',
|
||||
'URL::Encode' => '0.03',
|
||||
'URL::Encode::XS' => 0,
|
||||
'URL::Encode::XS' => '0',
|
||||
'YAML' => '0.84',
|
||||
'YAML::XS' => '0.41',
|
||||
},
|
||||
|
||||
5
Changes
5
Changes
@@ -1,5 +1,10 @@
|
||||
2.038033 - 2018-01-??
|
||||
|
||||
[NEW FEATURES]
|
||||
|
||||
* #228 timeout setting (default 10min) for backend jobs
|
||||
* #341 timeout setting for all actions ("<actionname>_timeout")
|
||||
|
||||
[BUG FIXES]
|
||||
|
||||
* #367 buttons in the neighbourmap have an incorrect height
|
||||
|
||||
@@ -6,9 +6,11 @@ use App::Netdisco::Util::Permission qw/check_acl_no check_acl_only/;
|
||||
use aliased 'App::Netdisco::Worker::Status';
|
||||
|
||||
use Try::Tiny;
|
||||
use Time::HiRes ();
|
||||
use Module::Load ();
|
||||
use Scope::Guard 'guard';
|
||||
use Storable 'dclone';
|
||||
use Sys::SigAction 'timeout_call';
|
||||
|
||||
use Moo::Role;
|
||||
use namespace::clean;
|
||||
@@ -55,12 +57,30 @@ sub run {
|
||||
my $configguard = guard { set(device_auth => \@userconf) };
|
||||
set(device_auth => \@newuserconf);
|
||||
|
||||
# run check phase and if there are workers then one MUST be successful
|
||||
$self->run_workers('workers_check');
|
||||
return if not $job->check_passed;
|
||||
my $runner = sub {
|
||||
my ($self, $job) = @_;
|
||||
|
||||
# run other phases
|
||||
$self->run_workers("workers_${_}") for qw/early main user/;
|
||||
# run check phase and if there are workers then one MUST be successful
|
||||
$self->run_workers('workers_check');
|
||||
|
||||
# run other phases
|
||||
if ($job->check_passed) {
|
||||
$self->run_workers("workers_${_}") for qw/early main user/;
|
||||
}
|
||||
};
|
||||
|
||||
my $maxtime = ((defined setting($job->action .'_timeout'))
|
||||
? setting($job->action .'_timeout') : setting('timeout'));
|
||||
if ($maxtime) {
|
||||
debug sprintf '%s: running with timeout %ss', $job->action, $maxtime;
|
||||
if (timeout_call($maxtime, $runner, ($self, $job))) {
|
||||
debug sprintf '%s: timed out!', $job->action;
|
||||
$job->add_status( Status->error("job timed out after $maxtime sec") );
|
||||
}
|
||||
}
|
||||
else {
|
||||
$runner->($self, $job);
|
||||
}
|
||||
}
|
||||
|
||||
sub run_workers {
|
||||
|
||||
@@ -199,6 +199,7 @@ snmptimeout: 3000000
|
||||
snmpretries: 2
|
||||
devices_no: []
|
||||
devices_only: []
|
||||
timeout: 600
|
||||
discover_no: []
|
||||
discover_only: []
|
||||
discover_no_type:
|
||||
|
||||
Reference in New Issue
Block a user