Skip to content

Commit

Permalink
Ensure CLI can shutdown cleanly with multiple queues and timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon committed Aug 5, 2021
1 parent 4152008 commit a56de0d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/good_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ def self.restart(timeout: -1)
_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.
# Sends +#shutdown+ or +#restart+ to executable objects ({GoodJob::Notifier}, {GoodJob::Poller}, {GoodJob::Scheduler}, {GoodJob::MultiScheduler}, {GoodJob::CronManager})
# @param executables [Array<Notifier, Poller, Scheduler, MultiScheduler, CronManager>] Objects to shut down.
# @param method_name [:symbol] Method to call, e.g. +:shutdown+ or +:restart+.
# @param timeout [nil,Numeric]
# @return [void]
def self._shutdown_all(executables, method_name = :shutdown, timeout: -1)
if timeout.positive?
if timeout.is_a?(Numeric) && timeout.positive?
executables.each { |executable| executable.send(method_name, timeout: nil) }

stop_at = Time.current + timeout
Expand Down

0 comments on commit a56de0d

Please sign in to comment.