Sha256: 9313f3cb5749f560b2fb106308a906c12db3aad5972b6a8a626c2e72c24861de

Contents?: true

Size: 715 Bytes

Versions: 12

Compression:

Stored size: 715 Bytes

Contents

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|
    ActiveRecord::Base.establish_connection
  end

  # you could also re-open them in the resque worker child, using
  # Resque.after_fork, but that probably isn't necessary, and
  # Resque::Pool.after_prefork should be faster, since it won't run
  # for every single job.
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
resque-pool-0.7.1 examples/rails-resque.rake
resque-pool-0.7.0 examples/rails-resque.rake
resque-pool-0.3.0 examples/rails-resque.rake
resque-pool-0.3.0.beta.2 examples/rails-resque.rake
vitobotta-resque-pool-0.3.2.dev examples/rails-resque.rake
vitobotta-resque-pool-0.3.1.dev examples/rails-resque.rake
vitobotta-resque-pool-0.3.0.dev examples/rails-resque.rake
resque-pool-0.3.0.beta.1 examples/rails-resque.rake
resque-pool-0.2.0 examples/rails-resque.rake
resque-pool-0.1.0 examples/rails-resque.rake
resque-pool-0.0.12.1.alpha examples/rails-resque.rake
resque-pool-0.0.12.0.alpha examples/rails-resque.rake