lib/good_job/capsule.rb in good_job-3.16.3 vs lib/good_job/capsule.rb in good_job-3.16.4

- old
+ new

@@ -27,17 +27,18 @@ return unless startable?(force: force) @mutex.synchronize do return unless startable?(force: force) - @notifier = GoodJob::Notifier.new(enable_listening: @configuration.enable_listen_notify) + @shared_executor = GoodJob::SharedExecutor.new + @notifier = GoodJob::Notifier.new(enable_listening: @configuration.enable_listen_notify, executor: @shared_executor.executor) @poller = GoodJob::Poller.new(poll_interval: @configuration.poll_interval) @scheduler = GoodJob::Scheduler.from_configuration(@configuration, warm_cache_on_initialize: true) @notifier.recipients << [@scheduler, :create_thread] @poller.recipients << [@scheduler, :create_thread] - @cron_manager = GoodJob::CronManager.new(@configuration.cron_entries, start_on_initialize: true) if @configuration.enable_cron? + @cron_manager = GoodJob::CronManager.new(@configuration.cron_entries, start_on_initialize: true, executor: @shared_executor.executor) if @configuration.enable_cron? @startable = false @running = true end end @@ -49,11 +50,11 @@ # * +N+ will wait at most N seconds and then interrupt active threads. # * +nil+ will trigger a shutdown but not wait for it to complete. # @return [void] def shutdown(timeout: :default) timeout = @configuration.shutdown_timeout if timeout == :default - GoodJob._shutdown_all([@notifier, @poller, @scheduler, @cron_manager].compact, timeout: timeout) + GoodJob._shutdown_all([@shared_executor, @notifier, @poller, @scheduler, @cron_manager].compact, timeout: timeout) @startable = false @running = false end # Shutdown and then start the capsule again. @@ -71,10 +72,10 @@ @running end # @return [Boolean] Whether the capsule has been shutdown. def shutdown? - [@notifier, @poller, @scheduler, @cron_manager].compact.all?(&:shutdown?) + [@shared_executor, @notifier, @poller, @scheduler, @cron_manager].compact.all?(&:shutdown?) end # Creates an execution thread(s) with the given attributes. # @param job_state [Hash, nil] See {GoodJob::Scheduler#create_thread}. # @return [Boolean, nil] Whether the thread was created.