#296 modification to add min_runtime optional sleep
This commit is contained in:
		| @@ -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 | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -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<sleep_time> is the number of seconds between polling the database to find | ||||
| new jobs. This is a balance between responsiveness and database load. | ||||
|  | ||||
| C<min_runtime> 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<schedule> | ||||
|  | ||||
| Value: Settings Tree. Default: None. | ||||
|   | ||||
| @@ -199,6 +199,7 @@ wap_ouis: [] | ||||
| workers: | ||||
|   tasks: 'AUTO * 2' | ||||
|   sleep_time: 1 | ||||
|   min_runtime: 0 | ||||
|   queue: PostgreSQL | ||||
|  | ||||
| dns: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user