lib/good_job.rb in good_job-1.11.3 vs lib/good_job.rb in good_job-1.12.0
- old
+ new
@@ -104,32 +104,28 @@
"Using `GoodJob.shutdown` with `wait:` kwarg is deprecated; use `timeout:` kwarg instead e.g. GoodJob.shutdown(timeout: #{wait ? '-1' : 'nil'})"
)
wait ? -1 : nil
end
- executables = Array(Notifier.instances) + Array(Poller.instances) + Array(Scheduler.instances)
- _shutdown_all(executables, timeout: timeout)
+ _shutdown_all(_executables, timeout: timeout)
end
# Tests whether jobs have stopped executing.
# @return [Boolean] whether background threads are shut down
def self.shutdown?
- Notifier.instances.all?(&:shutdown?) &&
- Poller.instances.all?(&:shutdown?) &&
- Scheduler.instances.all?(&:shutdown?)
+ _executables.all?(&:shutdown?)
end
# Stops and restarts executing jobs.
# GoodJob does its work in pools of background threads.
# When forking processes you should shut down these background threads before forking, and restart them after forking.
# For example, you should use +shutdown+ and +restart+ when using async execution mode with Puma.
# See the {file:README.md#executing-jobs-async--in-process} for more explanation and examples.
# @param timeout [Numeric, nil] Seconds to wait for active threads to finish.
# @return [void]
def self.restart(timeout: -1)
- executables = Array(Notifier.instances) + Array(Poller.instances) + Array(Scheduler.instances)
- _shutdown_all(executables, :restart, timeout: timeout)
+ _shutdown_all(_executables, :restart, timeout: timeout)
end
# Sends +#shutdown+ or +#restart+ to executable objects ({GoodJob::Notifier}, {GoodJob::Poller}, {GoodJob::Scheduler})
# @param executables [Array<Notifier, Poller, Scheduler, MultiScheduler>] Objects to shut down.
# @param method_name [:symbol] Method to call, e.g. +:shutdown+ or +:restart+.
@@ -142,9 +138,18 @@
stop_at = Time.current + timeout
executables.each { |executable| executable.send(method_name, timeout: [stop_at - Time.current, 0].max) }
else
executables.each { |executable| executable.send(method_name, timeout: timeout) }
end
+ end
+
+ def self._executables
+ [].concat(
+ CronManager.instances,
+ Notifier.instances,
+ Poller.instances,
+ Scheduler.instances
+ )
end
ActiveSupport.run_load_hooks(:good_job, self)
end