workerutil: Add automatic shutdown configuration
Created by: efritz
This PR adds optional configuration NumTotalJobs
and MaxActiveTime
that will cease job dequeues after the number of jobs have been processed or the given time has elapsed since the start of the worker, respectively.
This will enable us to have executors and dedicated job consumers which we only need to worry about scaling up when there are unprocessed jobs. Configuring a service to shut down automatically after (say) 4 hours of activity is a good way to boost capacity during a surge and naturally remove the instances that are no longer contributing to keeping load down. No app-level graceful-shutdown signal processing logic to worry about!