diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/World.cpp | 32 | ||||
-rw-r--r-- | src/game/World.h | 3 | ||||
-rw-r--r-- | src/trinitycore/trinitycore.conf.dist | 11 |
3 files changed, 46 insertions, 0 deletions
diff --git a/src/game/World.cpp b/src/game/World.cpp index 58af4efa4b8..a7d835ca6f9 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -831,6 +831,22 @@ void World::LoadConfigSettings(bool reload) m_timers[WUPDATE_UPTIME].Reset(); } + // log db cleanup interval + m_configs[CONFIG_LOGDB_CLEARINTERVAL] = sConfig.GetIntDefault("LogDB.Opt.ClearInternval", 10); + if(int32(m_configs[CONFIG_LOGDB_CLEARINTERVAL]) <= 0) + { + sLog.outError("LogDB.Opt.ClearInternval (%i) must be > 0, set to default 10.", m_configs[CONFIG_LOGDB_CLEARINTERVAL]); + m_configs[CONFIG_LOGDB_CLEARINTERVAL] = 10; + } + if(reload) + { + m_timers[WUPDATE_CLEANDB].SetInterval(m_configs[CONFIG_LOGDB_CLEARINTERVAL] * MINUTE * IN_MILISECONDS); + m_timers[WUPDATE_CLEANDB].Reset(); + } + m_configs[CONFIG_LOGDB_CLEARTIME] = sConfig.GetIntDefault("LogDB.Opt.ClearTime", 1209600); // 14 days default + sLog.outString("Will clear `logs` table of entries older than %i seconds every %u milliseconds.", + m_configs[CONFIG_LOGDB_CLEARTIME], m_configs[CONFIG_LOGDB_CLEARINTERVAL]); + m_configs[CONFIG_SKILL_CHANCE_ORANGE] = sConfig.GetIntDefault("SkillChance.Orange",100); m_configs[CONFIG_SKILL_CHANCE_YELLOW] = sConfig.GetIntDefault("SkillChance.Yellow",75); m_configs[CONFIG_SKILL_CHANCE_GREEN] = sConfig.GetIntDefault("SkillChance.Green",25); @@ -1466,6 +1482,8 @@ void World::SetInitialWorldSettings() //Update "uptime" table based on configuration entry in minutes. m_timers[WUPDATE_CORPSES].SetInterval(20*MINUTE*IN_MILISECONDS); //erase corpses every 20 minutes + m_timers[WUPDATE_CLEANDB].SetInterval(m_configs[CONFIG_LOGDB_CLEARINTERVAL]*MINUTE*IN_MILISECONDS); + // clean logs table every 14 days by default //to set mailtimer to return mails every day between 4 and 5 am //mailtimer is increased when updating auctions @@ -1694,6 +1712,20 @@ void World::Update(uint32 diff) WorldDatabase.PExecute("UPDATE uptime SET uptime = %d, maxplayers = %d WHERE starttime = " I64FMTD, tmpDiff, maxClientsNum, uint64(m_startTime)); } + /// <li> Clean logs table + if(sWorld.getConfig(CONFIG_LOGDB_CLEARTIME) > 0) // if not enabled, ignore the timer + { + if (m_timers[WUPDATE_CLEANDB].Passed()) + { + uint32 tmpDiff = (m_gameTime - m_startTime); + uint32 maxClientsNum = sWorld.GetMaxActiveSessionCount(); + + m_timers[WUPDATE_CLEANDB].Reset(); + LoginDatabase.PExecute("DELETE FROM logs WHERE (time + %u) < %u;", + sWorld.getConfig(CONFIG_LOGDB_CLEARTIME), uint64(time(0))); + } + } + /// <li> Handle all other objects if (m_timers[WUPDATE_OBJECTS].Passed()) { diff --git a/src/game/World.h b/src/game/World.h index f4195e94186..838dc873d07 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -68,6 +68,7 @@ enum WorldTimers WUPDATE_UPTIME = 4, WUPDATE_CORPSES = 5, WUPDATE_EVENTS = 6, + WUPDATE_CLEANDB = 7, WUPDATE_COUNT = 7 }; @@ -224,6 +225,8 @@ enum WorldConfigs CONFIG_CHATLOG_GUILD, CONFIG_CHATLOG_PUBLIC, CONFIG_CHATLOG_ADDON, + CONFIG_LOGDB_CLEARINTERVAL, + CONFIG_LOGDB_CLEARTIME, CONFIG_VALUE_COUNT }; diff --git a/src/trinitycore/trinitycore.conf.dist b/src/trinitycore/trinitycore.conf.dist index 94af98eac2a..dd09409d7a6 100644 --- a/src/trinitycore/trinitycore.conf.dist +++ b/src/trinitycore/trinitycore.conf.dist @@ -163,6 +163,15 @@ EAIErrorLevel = 2 # Update realm uptime period in minutes (for save data in 'uptime' table). Must be > 0 # Default: 10 (minutes) # +# LogDB.Opt.ClearInterval +# Time for the WUPDATE_CLEANDB timer that clears the `logs` table of old entries. Must be > 0. +# Default: 10 (minutes) +# +# LogDB.Opt.ClearTime +# The maximum time in seconds of old `logs` table entries to keep. +# Default: 1209600 (14 days) +# 0 - don't clear +# # MaxCoreStuckTime # Periodically check if the process got freezed, if this is the case force crash after the specified # amount of seconds. Must be > 0. Recommended > 10 secs if you use this. @@ -195,6 +204,8 @@ vmap.ignoreSpellIds = "7720" DetectPosCollision = 1 TargetPosRecalculateRange = 1.5 UpdateUptimeInterval = 10 +LogDB.Opt.ClearInterval = 10 +LogDB.Opt.ClearTime = 1209600 MaxCoreStuckTime = 0 AddonChannel = 1 |