This is your application when “MYSQL has gone away”
Most developers working with long running background processes will eventually run into the infamous “MySQL server has gone away” error. This error is thrown when the background processes are idle for an extended period of time and lose their active connection to the database.
The ensure_connected gem wraps any method with a check to ensure that you are connected to the database before performing work.
class Worker def do_something #do your work here. #you're connected to the database baby! end ensure_connected :do_something end
And Resque users have it even better with the resque-ensure-connected plugin. Simply drop this gem into your project and all of your background job invocations will be wrapped with the ensure_connected check. This works with the Backgrounded Resque integration as well!
As always, sourcecode is 100% opensource and available on Github.
Gems are available for download through Gemcutter.