From b7724bc16cfdaf04257cf519a75ed0081a6bc7c4 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Fri, 14 Apr 2017 21:24:02 +0100 Subject: [PATCH] #296 modification to add min_runtime optional sleep --- Netdisco/lib/App/Netdisco/Daemon/Worker/Common.pm | 2 ++ Netdisco/lib/App/Netdisco/Manual/Configuration.pod | 5 +++++ Netdisco/share/config.yml | 1 + 3 files changed, 8 insertions(+) diff --git a/Netdisco/lib/App/Netdisco/Daemon/Worker/Common.pm b/Netdisco/lib/App/Netdisco/Daemon/Worker/Common.pm index 4ae6ce1d..93df83d4 100644 --- a/Netdisco/lib/App/Netdisco/Daemon/Worker/Common.pm +++ b/Netdisco/lib/App/Netdisco/Daemon/Worker/Common.pm @@ -8,6 +8,7 @@ use App::Netdisco::Util::Daemon; use Role::Tiny; use namespace::clean; +use Time::HiRes 'sleep'; use App::Netdisco::JobQueue qw/jq_defer jq_complete/; sub worker_begin { (shift)->{started} = time } @@ -40,6 +41,7 @@ sub worker_body { }; $self->close_job($job); + sleep( setting('workers')->{'min_runtime'} || 0 ); $self->exit(0); # recycle worker } } diff --git a/Netdisco/lib/App/Netdisco/Manual/Configuration.pod b/Netdisco/lib/App/Netdisco/Manual/Configuration.pod index 0820c436..77b5d69b 100644 --- a/Netdisco/lib/App/Netdisco/Manual/Configuration.pod +++ b/Netdisco/lib/App/Netdisco/Manual/Configuration.pod @@ -1132,6 +1132,7 @@ Value: Settings Tree. Default: workers: tasks: 'AUTO * 2' sleep_time: 1 + min_runtime: 0 Control the activity of the backend daemon with this configuration setting. @@ -1145,6 +1146,10 @@ workers (which allows you to have a scheduler-only node). C is the number of seconds between polling the database to find new jobs. This is a balance between responsiveness and database load. +C allows you to set a time that each worker will sleep before +recycling and starting another job. Some users report this needs to be set +to avoid a 'runaway worker' bug. It can take a fractional number of seconds. + =head3 C Value: Settings Tree. Default: None. diff --git a/Netdisco/share/config.yml b/Netdisco/share/config.yml index 2a87ee4e..d3628239 100644 --- a/Netdisco/share/config.yml +++ b/Netdisco/share/config.yml @@ -199,6 +199,7 @@ wap_ouis: [] workers: tasks: 'AUTO * 2' sleep_time: 1 + min_runtime: 0 queue: PostgreSQL dns: