mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +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"
|
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
|
# LoginDatabase.WorkerThreads
|
||||||
# Description: The amount of worker threads spawned to handle asynchronous (delayed) MySQL
|
# 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
|
// Try reconnect
|
||||||
if (error == CR_CONNECTION_ERROR)
|
if (error == CR_CONNECTION_ERROR)
|
||||||
{
|
{
|
||||||
// Possible improvement for future: make ATTEMPTS and SECONDS configurable values
|
uint8 const ATTEMPTS = sConfigMgr->GetOption<uint8>("Database.Reconnect.Attempts", 20);
|
||||||
uint32 const ATTEMPTS = 5;
|
Seconds RECONNECT_SECONDS = Seconds(sConfigMgr->GetOption<uint8>("Database.Reconnect.Seconds", 15));
|
||||||
Seconds durationSecs = 5s;
|
uint8 count = 0;
|
||||||
uint32 count = 1;
|
|
||||||
|
|
||||||
auto sleepThread = [&]()
|
while (count < ATTEMPTS)
|
||||||
{
|
|
||||||
LOG_INFO("sql.driver", "> Retrying after %u seconds", static_cast<uint32>(durationSecs.count()));
|
|
||||||
std::this_thread::sleep_for(durationSecs);
|
|
||||||
};
|
|
||||||
|
|
||||||
sleepThread();
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
|
LOG_INFO("sql.driver", "> Retrying after %u seconds", static_cast<uint32>(RECONNECT_SECONDS.count()));
|
||||||
|
std::this_thread::sleep_for(RECONNECT_SECONDS);
|
||||||
error = pool.Open();
|
error = pool.Open();
|
||||||
|
|
||||||
if (error == CR_CONNECTION_ERROR)
|
if (error == CR_CONNECTION_ERROR)
|
||||||
{
|
{
|
||||||
sleepThread();
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -66,7 +58,7 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::st
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (count < ATTEMPTS);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the error wasn't handled quit
|
// 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"
|
WorldDatabaseInfo = "127.0.0.1;3306;acore;acore;acore_world"
|
||||||
CharacterDatabaseInfo = "127.0.0.1;3306;acore;acore;acore_characters"
|
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
|
# LoginDatabase.WorkerThreads
|
||||||
# WorldDatabase.WorkerThreads
|
# WorldDatabase.WorkerThreads
|
||||||
|
|||||||
Reference in New Issue
Block a user