lib/good_job/cli.rb in good_job-1.7.1 vs lib/good_job/cli.rb in good_job-1.8.0

- old
+ new

@@ -51,10 +51,14 @@ desc: "Interval between polls for available jobs in seconds (env var: GOOD_JOB_POLL_INTERVAL, default: 5)" method_option :max_cache, type: :numeric, banner: 'COUNT', desc: "Maximum number of scheduled jobs to cache in memory (env var: GOOD_JOB_MAX_CACHE, default: 10000)" + method_option :shutdown_timeout, + type: :numeric, + banner: 'SECONDS', + desc: "Number of seconds to wait for jobs to finish when shutting down before stopping the thread. (env var: GOOD_JOB_SHUTDOWN_TIMEOUT, default: -1 (forever))" method_option :daemonize, type: :boolean, desc: "Run as a background daemon (default: false)" method_option :pidfile, type: :string, @@ -79,12 +83,11 @@ Kernel.loop do sleep 0.1 break if @stop_good_job_executable || scheduler.shutdown? || notifier.shutdown? end - notifier.shutdown - poller.shutdown - scheduler.shutdown + executors = [notifier, poller, scheduler] + GoodJob._shutdown_all(executors, timeout: configuration.shutdown_timeout) end default_task :start # @!macro thor.desc