diff --git a/lib/tasks/resque.rake b/lib/tasks/resque.rake new file mode 100644 index 00000000..a84f7966 --- /dev/null +++ b/lib/tasks/resque.rake @@ -0,0 +1,14 @@ +require "resque/pool/tasks" + +task "resque:setup" => :environment + +task "resque:pool:setup" do + ActiveRecord::Base.connection_handler.clear_all_connections! + + # The pool master boots Rails and then forks each worker, so hand every child + # its own Redis and database connections instead of sharing the master's. + Resque::Pool.after_prefork do + Resque.redis.reconnect + ActiveRecord::Base.establish_connection + end +end