diff options
| author | Per Larsson <[email protected]> | 2021-11-18 18:50:09 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-11-18 18:50:09 +0100 |
| commit | 78ef39fdfa3c7ccf6531c3ff77baf2ca7e8a42ff (patch) | |
| tree | 8b0419f93d8a0b6002dd856222ffd998d51f71c4 /zenserver/zenserver.cpp | |
| parent | Change error code for failed upsteam apply (diff) | |
| download | zen-78ef39fdfa3c7ccf6531c3ff77baf2ca7e8a42ff.tar.xz zen-78ef39fdfa3c7ccf6531c3ff77baf2ca7e8a42ff.zip | |
Extended Health endpoint with support for returning build version and log file.
Diffstat (limited to 'zenserver/zenserver.cpp')
| -rw-r--r-- | zenserver/zenserver.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
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 |