resque will reconnect to database after each job to avoid Gone Away errors

This commit is contained in:
Emi Matchu 2013-03-05 15:14:29 -06:00
parent f547a75c40
commit 3cd06c9f64

View file

@ -1,3 +1,9 @@
# Sometimes the Resque workers have trouble maintaining their connections to
# Redis and to the database. It's not entirely clear when and why (though the
# internet suggests that it has to do with lying dormant for too long), but
# this fix ensures that Redis and the database are available at the start of
# every job.
Resque.after_fork do Resque.after_fork do
Resque.redis.client.reconnect Resque.redis.client.reconnect
ActiveRecord::Base.connection_handler.verify_active_connections!
end end