From ddded00d407beee65d5d87181a6e1f9dc360881c Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Thu, 17 Nov 2016 11:01:03 -0500 Subject: [PATCH 1/2] [Resque] Do not leak config in parent process --- lib/bugsnag/resque.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bugsnag/resque.rb b/lib/bugsnag/resque.rb index 4ec1ba845..f97380927 100644 --- a/lib/bugsnag/resque.rb +++ b/lib/bugsnag/resque.rb @@ -37,7 +37,7 @@ def save # Auto-load the failure backend Bugsnag::Resque.add_failure_backend -Resque.before_first_fork do +Resque.after_fork do Bugsnag.configuration.app_type = "resque" Bugsnag.configuration.default_delivery_method = :synchronous end From 091704afc425e50b400538a339e7222343d34f9e Mon Sep 17 00:00:00 2001 From: Martin Holman Date: Thu, 9 Feb 2017 10:07:35 -0800 Subject: [PATCH 2/2] depending on job fork configuration use a specific hook this should allow jobs that run inline to still have the app_type set correctly as before_first_fork is always called regardless of forking per worker or not. When forking is used for the jobs then the configuration will only be set in the forked worker --- lib/bugsnag/resque.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/bugsnag/resque.rb b/lib/bugsnag/resque.rb index f97380927..ff967243f 100644 --- a/lib/bugsnag/resque.rb +++ b/lib/bugsnag/resque.rb @@ -37,7 +37,14 @@ def save # Auto-load the failure backend Bugsnag::Resque.add_failure_backend -Resque.after_fork do - Bugsnag.configuration.app_type = "resque" - Bugsnag.configuration.default_delivery_method = :synchronous +if Resque::Worker.new.fork_per_job? + Resque.after_fork do + Bugsnag.configuration.app_type = "resque" + Bugsnag.configuration.default_delivery_method = :synchronous + end +else + Resque.before_first_fork do + Bugsnag.configuration.app_type = "resque" + Bugsnag.configuration.default_delivery_method = :synchronous + end end