Skip to content

Commit

Permalink
Ensure CLI can shutdown cleanly with multiple queues and timeout (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon committed Aug 5, 2021
1 parent 4152008 commit 1d8b155
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 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
2 changes: 1 addition & 1 deletion spec/lib/good_job/cron_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
cron_manager = described_class.new(schedules, start_on_initialize: true)

wait_until(max: 5) do
expect(GoodJob::Job.count).to eq 3
expect(GoodJob::Job.count).to be > 3
end

good_job = GoodJob::Job.first
Expand Down

0 comments on commit 1d8b155

Please sign in to comment.