def refresh_database_connection(database, options)
if options[:forced] or database_unreachable?(database)
begin
Thread.new do
disconnect_database database rescue nil
end.join configuration.options[:database_connection_timeout]
end
connect_exception = nil
Thread.new do
begin
connect_database database
rescue Exception => e
connect_exception = e
end
end.join configuration.options[:database_connection_timeout]
raise connect_exception if connect_exception
if database_unreachable?(database)
raise "no connection to '#{database}' database"
end
end
end