aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/config.h
blob: 8471ee89b0f11fac23f91450548a23cc8c171c00 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include <zencore/logbase.h>
#include <zencore/trace.h>
#include <zencore/zencore.h>
#include <zenhttp/httpserver.h>
#include <filesystem>
#include <string>
#include <vector>

namespace zen::LuaConfig {
struct Options;
}
namespace cxxopts {
class Options;
class ParseResult;
}  // namespace cxxopts
namespace zen {

struct ZenStorageServerOptions;

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 ZenServerOptions
{
	HttpServerConfig	  HttpServerConfig;
	ZenSentryConfig		  SentryConfig;
	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)
	bool				  NoConsoleOutput = false;	// Control default use of stdout for diagnostics
	bool				  QuietConsole	  = false;	// Configure console logger output to level WARN
	int					  CoreLimit		  = 0;		// If set, hardware concurrency queries are capped at this number
	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 AbsLogFile;	  // Absolute path to main log file
	std::string			  ChildId;		  // Id assigned by parent process (used for lifetime management)
	std::string			  LogId;		  // Id for tagging log output
	std::string			  Loggers[zen::logging::level::LogLevelCount];
#if ZEN_WITH_TRACE
	bool		 HasTraceCommandlineOptions = false;
	TraceOptions TraceOptions;
#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

	ZenStatsConfig StatsConfig;

	bool InstallService	  = false;	// Flag used to initiate service install (temporary)
	bool UninstallService = false;	// Flag used to initiate service uninstall (temporary)
};

void ParseCliOptions(int argc, char* argv[], ZenStorageServerOptions& ServerOptions);

void EmitCentralManifest(const std::filesystem::path& SystemRoot, Oid Identifier, CbObject Manifest, std::filesystem::path ManifestPath);
std::vector<CbObject> ReadAllCentralManifests(const std::filesystem::path& SystemRoot);

void AddServerConfigOptions(LuaConfig::Options& LuaOptions, ZenServerOptions& ServerOptions);

}  // namespace zen