From 78ef39fdfa3c7ccf6531c3ff77baf2ca7e8a42ff Mon Sep 17 00:00:00 2001 From: Per Larsson Date: Thu, 18 Nov 2021 18:50:09 +0100 Subject: Extended Health endpoint with support for returning build version and log file. --- zenserver/zenserver.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'zenserver/zenserver.cpp') diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index a330fb558..b36d84c22 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -151,16 +151,13 @@ namespace utils { class ZenServer : public IHttpStatusProvider { public: - void Initialize(ZenServiceConfig& ServiceConfig, - std::string_view HttpServerClass, - int BasePort, - int ParentPid, - ZenServerState::ZenServerEntry* ServerEntry) + void Initialize(ZenServiceConfig& ServiceConfig, const ZenServerOptions& ServerOptions, ZenServerState::ZenServerEntry* ServerEntry) { using namespace fmt::literals; m_ServerEntry = ServerEntry; m_DebugOptionForcedCrash = ServiceConfig.ShouldCrash; + const int ParentPid = ServerOptions.OwnerPid; if (ParentPid) { @@ -184,7 +181,7 @@ public: // Initialize/check mutex based on base port - std::string MutexName = "zen_{}"_format(BasePort); + std::string MutexName = "zen_{}"_format(ServerOptions.BasePort); if (zen::NamedMutex::Exists(MutexName) || ((m_ServerMutex.Create(MutexName) == false))) { @@ -193,10 +190,15 @@ public: InitializeState(ServiceConfig); + m_HealthService.SetHealthInfo({.DataRoot = m_DataRoot, + .AbsLogPath = ServerOptions.AbsLogFile, + .HttpServerClass = std::string(ServerOptions.HttpServerClass), + .BuildVersion = std::string(BUILD_VERSION)}); + // Ok so now we're configured, let's kick things off - m_Http = zen::CreateHttpServer(HttpServerClass); - m_Http->Initialize(BasePort); + m_Http = zen::CreateHttpServer(ServerOptions.HttpServerClass); + m_Http->Initialize(ServerOptions.BasePort); m_Http->RegisterService(m_HealthService); m_Http->RegisterService(m_StatsService); m_Http->RegisterService(m_StatusService); @@ -855,7 +857,7 @@ ZenWindowsService::Run() Server.SetContentRoot(GlobalOptions.ContentDir); Server.SetTestMode(GlobalOptions.IsTest); Server.SetDedicatedMode(GlobalOptions.IsDedicated); - Server.Initialize(ServiceConfig, GlobalOptions.HttpServerClass, GlobalOptions.BasePort, GlobalOptions.OwnerPid, Entry); + Server.Initialize(ServiceConfig, GlobalOptions, Entry); // Monitor shutdown signals -- cgit v1.2.3