Skip to content

Instantly share code, notes, and snippets.

@PatrickTulskie
Created October 25, 2012 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatrickTulskie/3955132 to your computer and use it in GitHub Desktop.
Save PatrickTulskie/3955132 to your computer and use it in GitHub Desktop.
Resque Pool and NewRelic
require 'resque/pool/tasks'
# this task will get called before resque:pool:setup
# preload the rails environment in the pool master
task "resque:setup" => :environment do
# generic worker setup, e.g. Hoptoad for failed jobs
end
task "resque:pool:setup" do
# close any sockets or files in pool master
ActiveRecord::Base.connection.disconnect!
# and re-open them in the resque worker parent
Resque::Pool.after_prefork do |job|
NewRelic::Agent.after_fork(:force_reconnect => true)
ActiveRecord::Base.establish_connection
end
end
@PatrickTulskie
Copy link
Author

After running this in production for a while, I have to say: Don't do this. For some reason, jobs just silently fail and die.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment