mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-20 19:52:48 +00:00
feat(master): report the UGC server in the server list and wait for it on shutdown
The server list now carries whether master starts the UGC server, whether it is connected and the pid it was started as. Settings reloads reach it like auth and chat, and shutdown waits for it. The UGC server sends its totals and storage with its traffic reports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -63,6 +63,13 @@ public:
|
||||
size_t Busy() const { std::lock_guard lock(m_Mutex); return m_Active; }
|
||||
size_t Threads() const { return m_Config.threads; }
|
||||
|
||||
// Main thread: totals since the start and the files' size (traffic reports, then the dashboard and /metrics)
|
||||
uint64_t Made() const { return m_Made; }
|
||||
uint64_t Failed() const { return m_Failed; }
|
||||
uint64_t Evicted() const { return m_Evicted; }
|
||||
uint64_t StoredBytes() const { return m_StoredBytes; }
|
||||
uint64_t MaxStorageBytes() const { return m_Config.maxStorageBytes; }
|
||||
|
||||
private:
|
||||
struct Job {
|
||||
Kind kind{};
|
||||
|
||||
@@ -323,6 +323,15 @@ int main(int argc, char** argv) {
|
||||
TrafficStats::Local().SetGauge("workers_busy", [&processor] { return static_cast<double>(processor.Busy()); });
|
||||
TrafficStats::Local().SetGauge("workers_queued", [&processor] { return static_cast<double>(processor.Queued()); });
|
||||
TrafficStats::Local().SetGauge("workers_threads", [&processor] { return static_cast<double>(processor.Threads()); });
|
||||
// Read on this thread, when a traffic report is taken (dServer::ReceiveFromMaster)
|
||||
const std::vector<std::pair<std::string, std::function<double()>>> ugcGauges{
|
||||
{ "ugc_made_total", [&processor] { return static_cast<double>(processor.Made()); } },
|
||||
{ "ugc_failed_total", [&processor] { return static_cast<double>(processor.Failed()); } },
|
||||
{ "ugc_evicted_total", [&processor] { return static_cast<double>(processor.Evicted()); } },
|
||||
{ "ugc_stored_bytes", [&processor] { return static_cast<double>(processor.StoredBytes()); } },
|
||||
{ "ugc_max_storage_bytes", [&processor] { return static_cast<double>(processor.MaxStorageBytes()); } },
|
||||
};
|
||||
for (const auto& [name, gauge] : ugcGauges) TrafficStats::Local().SetGauge(name, gauge);
|
||||
|
||||
const auto listenIp = Game::config->GetValue("listen_ip").empty() ? std::string("0.0.0.0") : Game::config->GetValue("listen_ip");
|
||||
const auto port = Setting<uint32_t>("port", 2008);
|
||||
@@ -355,6 +364,7 @@ int main(int argc, char** argv) {
|
||||
TrafficStats::Local().SetGauge("workers_busy", nullptr);
|
||||
TrafficStats::Local().SetGauge("workers_queued", nullptr);
|
||||
TrafficStats::Local().SetGauge("workers_threads", nullptr);
|
||||
for (const auto& [name, gauge] : ugcGauges) TrafficStats::Local().SetGauge(name, nullptr);
|
||||
Game::web.Shutdown();
|
||||
g_Processor = nullptr;
|
||||
Database::Destroy("UgcServer");
|
||||
|
||||
Reference in New Issue
Block a user