The Power to Reconnect MySQL in Rails

How do I get MySQL to reconnect at my will in a Rails application? I would like to do this either periodically or on database exceptions, for example, "MySQL server is gone."

I found ActiveRecord::Base.remove_connection, but as it is written, it should be called for some model, and not for the whole application.

+4
source share
2 answers

It is a huge pain to restart the Rails console when I run it through Heroku with a bunch of objects in variables and then lose the connection to the database.

, "" , Mysql2::Error: closed MySQL connection :

 ActiveRecord::Base.connection.reconnect!
+5

reconnect = true .yml, ?

+1

All Articles