// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include #include #include #include #include #include #include #include namespace zen::LuaConfig { struct Options; } namespace cxxopts { class Options; class ParseResult; } // namespace cxxopts namespace zen { // Common server configuration struct ZenStatsConfig { bool Enabled = false; std::string StatsdHost = "localhost"; int StatsdPort = 8125; }; struct ZenSentryConfig { bool Disable = false; bool AllowPII = false; // Allow personally identifiable information in sentry crash reports std::string Dsn; std::string Environment; bool Debug = false; // Enable debug mode for Sentry }; struct ZenServerConfig { HttpServerConfig HttpConfig; ZenSentryConfig SentryConfig; ZenStatsConfig StatsConfig; ZenLoggingConfig LoggingConfig; int BasePort = 8558; // Service listen port (used for both UDP and TCP) int OwnerPid = 0; // Parent process id (zero for standalone) bool IsDebug = false; bool IsCleanStart = false; // Indicates whether all state should be wiped on startup or not bool IsPowerCycle = false; // When true, the process shuts down immediately after initialization bool IsTest = false; bool Detach = true; // Whether zenserver should detach from existing process group (Mac/Linux) int CoreLimit = 0; // If set, hardware concurrency queries are capped at this number int LieCpu = 0; bool IsDedicated = false; // Indicates a dedicated/shared instance, with larger resource requirements bool ShouldCrash = false; // Option for testing crash handling bool IsFirstRun = false; std::filesystem::path ConfigFile; // Path to Lua config file std::filesystem::path SystemRootDir; // System root directory (used for machine level config) std::filesystem::path ContentDir; // Root directory for serving frontend content (experimental) std::filesystem::path DataDir; // Root directory for state (used for testing) std::filesystem::path BaseSnapshotDir; // Path to server state snapshot (will be copied into data dir on start) std::string ChildId; // Id assigned by parent process (used for lifetime management) std::filesystem::path SecurityConfigPath; // Path to a Json security configuration file #if ZEN_WITH_TRACE bool HasTraceCommandlineOptions = false; TraceOptions TraceCmdLineOptions; #endif std::string MemoryOptions; // Memory allocation options std::string CommandLine; std::string EncryptionKey; // 256 bit AES encryption key std::string EncryptionIV; // 128 bit AES initialization vector bool InstallService = false; // Flag used to initiate service install (temporary) bool UninstallService = false; // Flag used to initiate service uninstall (temporary) }; /** Configuration helper - pulls together command line, environment variables and config file parsing logic. Designed to allow a set of common configuration options to be shared among a set of applications which may or may not all be linked into a single executable. The virtual functions are used by derived classes to extend and customize the configuration process. */ struct ZenServerConfiguratorBase { ZenServerConfiguratorBase(ZenServerConfig& BaseServerOptions); virtual ~ZenServerConfiguratorBase(); void Configure(int argc, char* argv[]); protected: virtual void AddCliOptions(cxxopts::Options& options) = 0; virtual void ApplyOptions(cxxopts::Options& options) = 0; virtual void ValidateOptions() = 0; virtual void AddConfigOptions(LuaConfig::Options& Options) = 0; virtual void OnConfigFileParsed(LuaConfig::Options& LuaOptions) = 0; private: ZenServerConfig& m_ServerOptions; void ParseEnvVariables(const cxxopts::ParseResult& CmdLineResult); void ParseConfigFile(const std::filesystem::path& Path, const cxxopts::ParseResult& CmdLineResult, std::string_view OutputConfigFile); void AddCommonConfigOptions(LuaConfig::Options& LuaOptions); }; void EmitCentralManifest(const std::filesystem::path& SystemRoot, Oid Identifier, CbObject Manifest, std::filesystem::path ManifestPath); std::vector ReadAllCentralManifests(const std::filesystem::path& SystemRoot); } // namespace zen