lib/bugsnag/integrations/resque.rb in bugsnag-6.16.0 vs lib/bugsnag/integrations/resque.rb in bugsnag-6.17.0

- old
+ new

@@ -56,18 +56,25 @@ Resque::Failure::Bugsnag = Bugsnag::Resque # Auto-load the failure backend Bugsnag::Resque.add_failure_backend -if Resque::Worker.new(:bugsnag_fork_check).fork_per_job? +worker = Resque::Worker.new(:bugsnag_fork_check) + +# If at_exit hooks are not enabled then we can't use the thread queue delivery +# method because it relies on an at_exit hook to ensure the queue is flushed +can_use_thread_queue = worker.respond_to?(:run_at_exit_hooks) && worker.run_at_exit_hooks +default_delivery_method = can_use_thread_queue ? :thread_queue : :synchronous + +if worker.fork_per_job? Resque.after_fork do Bugsnag.configuration.detected_app_type = "resque" - Bugsnag.configuration.default_delivery_method = :synchronous + Bugsnag.configuration.default_delivery_method = default_delivery_method Bugsnag.configuration.runtime_versions["resque"] = ::Resque::VERSION end else Resque.before_first_fork do Bugsnag.configuration.detected_app_type = "resque" - Bugsnag.configuration.default_delivery_method = :synchronous + Bugsnag.configuration.default_delivery_method = default_delivery_method Bugsnag.configuration.runtime_versions["resque"] = ::Resque::VERSION end end