On Sep 30, 3:34 am, Gerhard <[email protected]> wrote: > I've used the standard DB constant approach for connecting to a MySQL > db: > > DB = Sequel::Mysql2::Database.connect(mysql_options) > > When the MySQL servers gets restarted, all subsequent connections > fail: > > Sequel::DatabaseDisconnectError: Mysql2::Error: MySQL server has gone > away > > I'm now connecting using Sequel::Document: > > def connect! > Sequel::Model.db = Sequel::Mysql2::Database.connect(mysql_options) > end > > I call this method when starting the app and would like to call it on > Sequel::DatabaseDisconnectError, but I can't figure out where to > rescue. Maybe my approach is wrong...
You shouldn't need to do that. When a DatabaseDisconnectError is raised, the related connection should be removed from the connection pool, and then the next time a connection is needed, a new connection should be created. At most you should only get as many DatabaseDisconnectErrors as you have active connections. Note that you should not do: DB = Sequel::Mysql2::Database.connect(mysql_options) Not sure where you saw that, but it's wrong. You should just call Sequel.connect: DB = Sequel.connect(mysql_options) # where mysql_options contains :adapter=>'mysql2' Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
