mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-22 12:29:46 +01:00
Add db-reconnect adminverb (#1398)
Adds a Reconnect-SQL verb to admins with permission flag R_DEBUG, as well as making the server attempt to automatically reconnect to SQL on connection drop.
This commit is contained in:
@@ -70,6 +70,10 @@ DBConnection/proc/Connect(dbi_handler = con_dbi, user_handler = con_user, passwo
|
||||
DBConnection/proc/Disconnect()
|
||||
return _dm_db_close(_db_con)
|
||||
|
||||
DBConnection/proc/Reconnect()
|
||||
Disconnect()
|
||||
Connect()
|
||||
|
||||
DBConnection/proc/IsConnected()
|
||||
if(!config.sql_enabled)
|
||||
return 0
|
||||
@@ -122,8 +126,15 @@ DBQuery/proc/Execute(var/list/argument_list = null, var/pass_not_found = 0, sql_
|
||||
|
||||
var/result = _dm_db_execute(_db_query, sql_query, db_connection._db_con, cursor_handler, null)
|
||||
|
||||
if (ErrorMsg())
|
||||
error("SQL Error: '[ErrorMsg()]'")
|
||||
var/error = ErrorMsg()
|
||||
if (error)
|
||||
error("SQL Error: '[error]'")
|
||||
// This is hacky and should probably be changed
|
||||
if (error == "MySQL server has gone away")
|
||||
log_and_message_admins("is attempting to reconnect the server to MySQL. (Connection Failure)")
|
||||
dbcon.Reconnect()
|
||||
if (db_connection.IsConnected())
|
||||
src.Execute(argument_list)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user