lib/fulmar/infrastructure/service/database/database_service.rb in fulmar-1.8.4 vs lib/fulmar/infrastructure/service/database/database_service.rb in fulmar-1.8.5

- old
+ new

@@ -38,15 +38,16 @@ tunnel.open options[:port] = tunnel.local_port end # Wait max 3 seconds for the tunnel to establish - 4.times do |i| + 6.times do |i| break if try_connect(options, i) end @connected = true + query("USE #{@config[:maria][:database]}") end def disconnect @connected = false @client.close @@ -61,11 +62,11 @@ @tunnel ||= Fulmar::Infrastructure::Service::TunnelService.new(@config.ssh_user_and_host, @config[:maria][:port], @config[:maria][:hostname]) end # shortcut for DatabaseService.client.query def query(*arguments) - @client.query(arguments) + @client.query(*arguments) end def create(name) state_before = connected? connect unless connected? @@ -121,11 +122,11 @@ protected def try_connect(options, i) @client = Mysql2::Client.new options rescue Mysql2::Error => e - sleep 1 if i < 3 - raise e.message if i == 3 + sleep 1 if i < 5 + raise e.message if i == 5 end # Return mysql command line options to ignore specific tables def ignore_tables @config[:maria][:ignore_tables] = [*@config[:maria][:ignore_tables]]