From 3ebd53b7c74bf7d3379f0ad4eb83d75bb76dde01 Mon Sep 17 00:00:00 2001 From: MrStonedOne Date: Fri, 24 Oct 2014 11:21:15 -0700 Subject: [PATCH] Adds new admin verb to reconnect to the database when the connection dies. --- code/modules/admin/admin_verbs.dm | 4 ++- .../admin/verbs/reestablish_db_connection.dm | 27 +++++++++++++++++++ tgstation.dme | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 code/modules/admin/verbs/reestablish_db_connection.dm diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 040cf890a2d..6280afc88eb 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -14,6 +14,7 @@ var/list/admin_verbs_default = list( /client/proc/investigate_show, /*various admintools for investigation. Such as a singulo grief-log*/ /client/proc/secrets, /client/proc/reload_admins, + /client/proc/reestablish_db_connection,/*reattempt a connection to the database*/ /client/proc/cmd_admin_pm_context, /*right-click adminPM interface*/ /client/proc/cmd_admin_pm_panel /*admin-pm list*/ ) @@ -184,7 +185,8 @@ var/list/admin_verbs_hideable = list( /client/proc/cmd_debug_del_all, /client/proc/enable_debug_verbs, /proc/possess, - /proc/release + /proc/release, + /client/proc/reload_admins ) /client/proc/add_admin_verbs() diff --git a/code/modules/admin/verbs/reestablish_db_connection.dm b/code/modules/admin/verbs/reestablish_db_connection.dm new file mode 100644 index 00000000000..67586501bb5 --- /dev/null +++ b/code/modules/admin/verbs/reestablish_db_connection.dm @@ -0,0 +1,27 @@ +/client/proc/reestablish_db_connection() + set category = "Special Verbs" + set name = "Reestablish DB Connection" + + if (dbcon && dbcon.IsConnected()) + if (!check_rights(R_DEBUG,0)) + alert("The database is already connected! (Only those with +debug can force a reconnection)", "The database is already connected!") + return + + var/reconnect = alert("The database is already connected! If you *KNOW* that this is incorrect, you can force a reconnection", "The database is already connected!", "Force Reconnect", "Cancel") + if (reconnect != "Force Reconnect") + return + + dbcon.Disconnect() + failed_db_connections = 0 + log_admin("[key_name(usr)] Has forced the database to reconnect") + message_admins("[key_name_admin(usr)] Has forced the database to reconnect") + feedback_add_details("admin_verb","FRDB") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! + + + failed_db_connections = 0 + spawn(0) + establish_db_connection() + + log_admin("[key_name(usr)] Has re-established the DB Connection") + message_admins("[key_name_admin(usr)] Has re-established the DB Connection") + feedback_add_details("admin_verb","RDB") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! \ No newline at end of file diff --git a/tgstation.dme b/tgstation.dme index c182a9a781f..325017e930c 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -741,6 +741,7 @@ #include "code\modules\admin\verbs\possess.dm" #include "code\modules\admin\verbs\pray.dm" #include "code\modules\admin\verbs\randomverbs.dm" +#include "code\modules\admin\verbs\reestablish_db_connection.dm" #include "code\modules\admin\verbs\ticklag.dm" #include "code\modules\admin\verbs\tripAI.dm" #include "code\modules\admin\verbs\SDQL2\SDQL_2.dm"