// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "zenserver.h" #include #include #include #include #include #include #include "admin/admin.h" #include "buildstore/httpbuildstore.h" #include "cache/httpstructuredcache.h" #include "diag/diagsvcs.h" #include "frontend/frontend.h" #include "objectstore/objectstore.h" #include "projectstore/httpprojectstore.h" #include "stats/statsreporter.h" #include "upstream/upstream.h" #include "vfs/vfsservice.h" #include "workspaces/httpworkspaces.h" namespace zen { class ZenStorageServer : public ZenServerBase { ZenStorageServer& operator=(ZenStorageServer&&) = delete; ZenStorageServer(ZenStorageServer&&) = delete; public: ZenStorageServer(); ~ZenStorageServer(); void SetDedicatedMode(bool State) { m_IsDedicatedMode = State; } void SetTestMode(bool State) { m_TestMode = State; } void SetDataRoot(std::filesystem::path Root) { m_DataRoot = Root; } void SetContentRoot(std::filesystem::path Root) { m_ContentRoot = Root; } int Initialize(const ZenStorageServerConfig& ServerOptions, ZenServerState::ZenServerEntry* ServerEntry); void Run(); void Cleanup(); private: void InitializeState(const ZenStorageServerConfig& ServerOptions); void InitializeStructuredCache(const ZenStorageServerConfig& ServerOptions); void Flush(); bool m_IsDedicatedMode = false; bool m_TestMode = false; bool m_DebugOptionForcedCrash = false; std::string m_StartupScrubOptions; CbObject m_RootManifest; std::filesystem::path m_DataRoot; std::filesystem::path m_ContentRoot; asio::steady_timer m_StateMarkerTimer{m_IoContext}; void EnqueueStateMarkerTimer(); void CheckStateMarker(); std::unique_ptr m_AuthMgr; std::unique_ptr m_AuthService; void InitializeAuthentication(const ZenStorageServerConfig& ServerOptions); void InitializeServices(const ZenStorageServerConfig& ServerOptions); void RegisterServices(); HttpStatsService m_StatsService; std::unique_ptr m_JobQueue; GcManager m_GcManager; GcScheduler m_GcScheduler{m_GcManager}; std::unique_ptr m_CidStore; Ref m_CacheStore; std::unique_ptr m_OpenProcessCache; HttpTestService m_TestService; std::unique_ptr m_BuildCidStore; std::unique_ptr m_BuildStore; #if ZEN_WITH_TESTS HttpTestingService m_TestingService; #endif RefPtr m_ProjectStore; std::unique_ptr m_VfsServiceImpl; std::unique_ptr m_HttpProjectService; std::unique_ptr m_Workspaces; std::unique_ptr m_HttpWorkspacesService; std::unique_ptr m_UpstreamCache; std::unique_ptr m_UpstreamService; std::unique_ptr m_StructuredCacheService; std::unique_ptr m_FrontendService; std::unique_ptr m_ObjStoreService; std::unique_ptr m_BuildStoreService; std::unique_ptr m_VfsService; std::unique_ptr m_AdminService; }; struct ZenStorageServerConfigurator; class ZenStorageServerMain : public ZenServerMain { public: ZenStorageServerMain(ZenStorageServerConfig& ServerOptions); ~ZenStorageServerMain(); virtual void DoRun(ZenServerState::ZenServerEntry* Entry) override; virtual void InitializeLogging() override; ZenStorageServerMain(const ZenStorageServerMain&) = delete; ZenStorageServerMain& operator=(const ZenStorageServerMain&) = delete; typedef ZenStorageServerConfig Config; typedef ZenStorageServerConfigurator Configurator; private: ZenStorageServerConfig& m_ServerOptions; }; } // namespace zen