Method: Rpush::Daemon::Store::ActiveRecord::Reconnectable#database_connection_lost

Defined in:
lib/rpush/daemon/store/active_record/reconnectable.rb

#database_connection_lostObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/rpush/daemon/store/active_record/reconnectable.rb', line 46

def database_connection_lost
  Rpush.logger.warn("Lost connection to database, reconnecting...")
  attempts = 0
  loop do
    begin
      Rpush.logger.warn("Attempt #{attempts += 1}")
      reconnect_database
      check_database_is_connected
      break
    rescue *ADAPTER_ERRORS => e
      Rpush.logger.error(e)
      sleep_to_avoid_thrashing
    end
  end
  Rpush.logger.warn("Database reconnected")
end