diff options
| author | Per Larsson <[email protected]> | 2022-01-28 13:07:36 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2022-01-28 13:07:36 +0100 |
| commit | bd43839e042425d72b584b33c7dbb86dabc95e12 (patch) | |
| tree | 1e663395ac626f3863ef92e95952b3c4245abf76 /zenserver/zenserver.cpp | |
| parent | Get access token from auth mgr. (diff) | |
| parent | Compile fix (diff) | |
| download | zen-bd43839e042425d72b584b33c7dbb86dabc95e12.tar.xz zen-bd43839e042425d72b584b33c7dbb86dabc95e12.zip | |
Merged main.
Diffstat (limited to 'zenserver/zenserver.cpp')
| -rw-r--r-- | zenserver/zenserver.cpp | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index e96a4ceaa..bd4a3c1cf 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -156,7 +156,7 @@ namespace utils { class ZenServer : public IHttpStatusProvider { public: - void Initialize(const ZenServerOptions& ServerOptions, ZenServerState::ZenServerEntry* ServerEntry) + int Initialize(const ZenServerOptions& ServerOptions, ZenServerState::ZenServerEntry* ServerEntry) { m_UseSentry = ServerOptions.NoSentry == false; m_ServerEntry = ServerEntry; @@ -201,8 +201,8 @@ public: // Ok so now we're configured, let's kick things off - m_Http = zen::CreateHttpServer(ServerOptions.HttpServerClass); - m_Http->Initialize(ServerOptions.BasePort); + m_Http = zen::CreateHttpServer(ServerOptions.HttpServerClass); + int EffectiveBasePort = m_Http->Initialize(ServerOptions.BasePort); m_AuthMgr = MakeAuthMgr({.RootDirectory = m_DataRoot / "auth"}); m_AuthService = std::make_unique<zen::HttpAuthService>(*m_AuthMgr); @@ -267,7 +267,7 @@ public: #if ZEN_ENABLE_MESH if (ServerOptions.MeshEnabled) { - StartMesh(BasePort); + StartMesh(EffectiveBasePort); } else { @@ -314,6 +314,8 @@ public: .Enabled = ServerOptions.GcConfig.Enabled, }; m_GcScheduler.Initialize(GcConfig); + + return EffectiveBasePort; } void InitializeState(const ZenServerOptions& ServerOptions); @@ -684,7 +686,6 @@ void ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions) { using namespace std::literals; - auto ValueOrDefault = [](std::string_view Value, std::string_view Default) { return Value.empty() ? Default : Value; }; ZEN_INFO("instantiating structured cache service"); m_CacheStore = std::make_unique<ZenCacheStore>(m_CasGc, m_DataRoot / "cache"); @@ -728,8 +729,10 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions) if (!ZenUrls.empty()) { + const auto ZenEndpointName = UpstreamConfig.ZenConfig.Name.empty() ? "Zen"sv : UpstreamConfig.ZenConfig.Name; + std::unique_ptr<zen::UpstreamEndpoint> ZenEndpoint = - zen::MakeZenUpstreamEndpoint({.Name = "Zen"sv, + zen::MakeZenUpstreamEndpoint({.Name = ZenEndpointName, .Urls = ZenUrls, .ConnectTimeout = std::chrono::milliseconds(UpstreamConfig.ConnectTimeoutMilliseconds), .Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds)}); @@ -743,7 +746,7 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions) if (UpstreamConfig.JupiterConfig.UseProductionSettings) { Options = - zen::CloudCacheClientOptions{.Name = "Horde"sv, + zen::CloudCacheClientOptions{.Name = "Jupiter-Prod"sv, .ServiceUrl = "https://jupiter.devtools.epicgames.com"sv, .DdcNamespace = "ue.ddc"sv, .BlobStoreNamespace = "ue.ddc"sv, @@ -757,7 +760,7 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions) else if (UpstreamConfig.JupiterConfig.UseDevelopmentSettings) { Options = - zen::CloudCacheClientOptions{.Name = "Horde"sv, + zen::CloudCacheClientOptions{.Name = "Jupiter-Dev"sv, .ServiceUrl = "https://jupiter.devtools-dev.epicgames.com"sv, .DdcNamespace = "ue.ddc"sv, .BlobStoreNamespace = "ue.ddc"sv, @@ -768,14 +771,23 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions) .Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds), .UseLegacyDdc = false}; } + else + { + const auto JupiterEndpointName = + UpstreamConfig.JupiterConfig.Name.empty() ? "Jupiter"sv : UpstreamConfig.JupiterConfig.Name; - Options.ServiceUrl = ValueOrDefault(UpstreamConfig.JupiterConfig.Url, Options.ServiceUrl); - Options.DdcNamespace = ValueOrDefault(UpstreamConfig.JupiterConfig.DdcNamespace, Options.DdcNamespace); - Options.BlobStoreNamespace = ValueOrDefault(UpstreamConfig.JupiterConfig.Namespace, Options.BlobStoreNamespace); - Options.OAuthProvider = ValueOrDefault(UpstreamConfig.JupiterConfig.OAuthProvider, Options.OAuthProvider); - Options.OAuthClientId = ValueOrDefault(UpstreamConfig.JupiterConfig.OAuthClientId, Options.OAuthClientId); - Options.OAuthSecret = ValueOrDefault(UpstreamConfig.JupiterConfig.OAuthClientSecret, Options.OAuthSecret); - Options.UseLegacyDdc |= UpstreamConfig.JupiterConfig.UseLegacyDdc; + Options = + zen::CloudCacheClientOptions{.Name = JupiterEndpointName, + .ServiceUrl = UpstreamConfig.JupiterConfig.Url, + .DdcNamespace = UpstreamConfig.JupiterConfig.DdcNamespace, + .BlobStoreNamespace = UpstreamConfig.JupiterConfig.Namespace, + .OAuthProvider = UpstreamConfig.JupiterConfig.OAuthProvider, + .OAuthClientId = UpstreamConfig.JupiterConfig.OAuthClientId, + .OAuthSecret = UpstreamConfig.JupiterConfig.OAuthClientSecret, + .ConnectTimeout = std::chrono::milliseconds(UpstreamConfig.ConnectTimeoutMilliseconds), + .Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds), + .UseLegacyDdc = false}; + } if (!Options.ServiceUrl.empty()) { @@ -885,6 +897,20 @@ ZenEntryPoint::Run() Entry->AddSponsorProcess(ServerOptions.OwnerPid); } + ZenServer Server; + Server.SetDataRoot(ServerOptions.DataDir); + Server.SetContentRoot(ServerOptions.ContentDir); + Server.SetTestMode(ServerOptions.IsTest); + Server.SetDedicatedMode(ServerOptions.IsDedicated); + int EffectiveBasePort = Server.Initialize(ServerOptions, Entry); + + Entry->EffectiveListenPort = uint16_t(EffectiveBasePort); + if (EffectiveBasePort != ServerOptions.BasePort) + { + ZEN_INFO(ZEN_APP_NAME " - relocated to base port {}", EffectiveBasePort); + ServerOptions.BasePort = EffectiveBasePort; + } + std::unique_ptr<std::thread> ShutdownThread; std::unique_ptr<zen::NamedEvent> ShutdownEvent; @@ -892,13 +918,6 @@ ZenEntryPoint::Run() ShutdownEventName << "Zen_" << ServerOptions.BasePort << "_Shutdown"; ShutdownEvent.reset(new zen::NamedEvent{ShutdownEventName}); - ZenServer Server; - Server.SetDataRoot(ServerOptions.DataDir); - Server.SetContentRoot(ServerOptions.ContentDir); - Server.SetTestMode(ServerOptions.IsTest); - Server.SetDedicatedMode(ServerOptions.IsDedicated); - Server.Initialize(ServerOptions, Entry); - // Monitor shutdown signals ShutdownThread.reset(new std::thread{[&] { |