diff --git a/config/initializers/resque.rb b/config/initializers/resque.rb index 13a71e19..5b8e4ddb 100644 --- a/config/initializers/resque.rb +++ b/config/initializers/resque.rb @@ -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.redis.client.reconnect + ActiveRecord::Base.connection_handler.verify_active_connections! end