mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Shared/Metric: Fix crash on shutdown
Fix crash on shutdown with metrics enabled but InfluxDB stopping before worldserver
(cherry picked from commit 45b2bcfaf2)
This commit is contained in:
@@ -213,16 +213,17 @@ void Metric::ScheduleSend()
|
||||
}
|
||||
}
|
||||
|
||||
void Metric::ForceSend()
|
||||
void Metric::Unload()
|
||||
{
|
||||
// Send what's queued only if IoContext is stopped (so only on shutdown)
|
||||
if (_enabled && Trinity::Asio::get_io_context(*_batchTimer).stopped())
|
||||
{
|
||||
_enabled = false;
|
||||
SendBatch();
|
||||
_batchTimer->cancel();
|
||||
_overallStatusTimer->cancel();
|
||||
}
|
||||
|
||||
_batchTimer->cancel();
|
||||
_overallStatusTimer->cancel();
|
||||
}
|
||||
|
||||
void Metric::ScheduleOverallStatusLog()
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
|
||||
void LogEvent(std::string const& category, std::string const& title, std::string const& description);
|
||||
|
||||
void ForceSend();
|
||||
void Unload();
|
||||
bool IsEnabled() const { return _enabled; }
|
||||
};
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ extern int main(int argc, char** argv)
|
||||
std::shared_ptr<void> sMetricHandle(nullptr, [](void*)
|
||||
{
|
||||
TC_METRIC_EVENT("events", "Worldserver shutdown", "");
|
||||
sMetric->ForceSend();
|
||||
sMetric->Unload();
|
||||
});
|
||||
|
||||
sScriptMgr->SetScriptLoader(AddScripts);
|
||||
|
||||
Reference in New Issue
Block a user