mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 03:15:41 +00:00
feat(Core/DB): reconnect seconds and attempts configurable (#5673)
This commit is contained in:
@@ -150,6 +150,18 @@ WrongPass.Logging = 0
|
||||
|
||||
LoginDatabaseInfo = "127.0.0.1;3306;acore;acore;acore_auth"
|
||||
|
||||
#
|
||||
# Database.Reconnect.Seconds
|
||||
# Database.Reconnect.Attempts
|
||||
#
|
||||
# Description: How many seconds between every reconnection attempt
|
||||
# and how many attempts will be performed in total
|
||||
# Default: 20 attempts every 15 seconds
|
||||
#
|
||||
|
||||
Database.Reconnect.Seconds = 15
|
||||
Database.Reconnect.Attempts = 20
|
||||
|
||||
#
|
||||
# LoginDatabase.WorkerThreads
|
||||
# Description: The amount of worker threads spawned to handle asynchronous (delayed) MySQL
|
||||
|
||||
@@ -39,26 +39,18 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::st
|
||||
// Try reconnect
|
||||
if (error == CR_CONNECTION_ERROR)
|
||||
{
|
||||
// Possible improvement for future: make ATTEMPTS and SECONDS configurable values
|
||||
uint32 const ATTEMPTS = 5;
|
||||
Seconds durationSecs = 5s;
|
||||
uint32 count = 1;
|
||||
uint8 const ATTEMPTS = sConfigMgr->GetOption<uint8>("Database.Reconnect.Attempts", 20);
|
||||
Seconds RECONNECT_SECONDS = Seconds(sConfigMgr->GetOption<uint8>("Database.Reconnect.Seconds", 15));
|
||||
uint8 count = 0;
|
||||
|
||||
auto sleepThread = [&]()
|
||||
{
|
||||
LOG_INFO("sql.driver", "> Retrying after %u seconds", static_cast<uint32>(durationSecs.count()));
|
||||
std::this_thread::sleep_for(durationSecs);
|
||||
};
|
||||
|
||||
sleepThread();
|
||||
|
||||
do
|
||||
while (count < ATTEMPTS)
|
||||
{
|
||||
LOG_INFO("sql.driver", "> Retrying after %u seconds", static_cast<uint32>(RECONNECT_SECONDS.count()));
|
||||
std::this_thread::sleep_for(RECONNECT_SECONDS);
|
||||
error = pool.Open();
|
||||
|
||||
if (error == CR_CONNECTION_ERROR)
|
||||
{
|
||||
sleepThread();
|
||||
count++;
|
||||
}
|
||||
else
|
||||
@@ -66,7 +58,7 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::st
|
||||
break;
|
||||
}
|
||||
|
||||
} while (count < ATTEMPTS);
|
||||
}
|
||||
}
|
||||
|
||||
// If the error wasn't handled quit
|
||||
|
||||
@@ -95,6 +95,18 @@ LoginDatabaseInfo = "127.0.0.1;3306;acore;acore;acore_auth"
|
||||
WorldDatabaseInfo = "127.0.0.1;3306;acore;acore;acore_world"
|
||||
CharacterDatabaseInfo = "127.0.0.1;3306;acore;acore;acore_characters"
|
||||
|
||||
#
|
||||
# Database.Reconnect.Seconds
|
||||
# Database.Reconnect.Attempts
|
||||
#
|
||||
# Description: How many seconds between every reconnection attempt
|
||||
# and how many attempts will be performed in total
|
||||
# Default: 20 attempts every 15 seconds
|
||||
#
|
||||
|
||||
Database.Reconnect.Seconds = 15
|
||||
Database.Reconnect.Attempts = 20
|
||||
|
||||
#
|
||||
# LoginDatabase.WorkerThreads
|
||||
# WorldDatabase.WorkerThreads
|
||||
|
||||
Reference in New Issue
Block a user