aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-15 10:04:50 +0200
committerStefan Boberg <[email protected]>2021-09-15 10:04:50 +0200
commitb5d89b30f29f12c14e5968a68118519118135fea (patch)
tree49c4f657d8839b7a120ec6b6dacefbfea38d9c8d
parentUpdated function service to new package management API (diff)
downloadzen-b5d89b30f29f12c14e5968a68118519118135fea.tar.xz
zen-b5d89b30f29f12c14e5968a68118519118135fea.zip
Added options for indicating a server is running in "dedicated" mode
I.e running on a host to serve *remote* clients
-rw-r--r--zenserver/config.cpp1
-rw-r--r--zenserver/config.h15
-rw-r--r--zenserver/zenserver.cpp5
3 files changed, 13 insertions, 8 deletions
diff --git a/zenserver/config.cpp b/zenserver/config.cpp
index ddef83c02..abd69be25 100644
--- a/zenserver/config.cpp
+++ b/zenserver/config.cpp
@@ -59,6 +59,7 @@ void
ParseGlobalCliOptions(int argc, char* argv[], ZenServerOptions& GlobalOptions, ZenServiceConfig& ServiceConfig)
{
cxxopts::Options options("zenserver", "Zen Server");
+ options.add_options()("dedicated", "Enable dedicated server mode", cxxopts::value<bool>(GlobalOptions.IsDedicated)->default_value("false"));
options.add_options()("d, debug", "Enable debugging", cxxopts::value<bool>(GlobalOptions.IsDebug)->default_value("false"));
options.add_options()("help", "Show command line help");
options.add_options()("t, test", "Enable test mode", cxxopts::value<bool>(GlobalOptions.IsTest)->default_value("false"));
diff --git a/zenserver/config.h b/zenserver/config.h
index 92b7c9e31..80ec86905 100644
--- a/zenserver/config.h
+++ b/zenserver/config.h
@@ -7,13 +7,14 @@
struct ZenServerOptions
{
- bool IsDebug = false;
- bool IsTest = false;
- int BasePort = 1337; // Service listen port (used for both UDP and TCP)
- int OwnerPid = 0; // Parent process id (zero for standalone)
- std::string ChildId; // Id assigned by parent process (used for lifetime management)
- std::string LogId; // Id for tagging log output
- std::filesystem::path DataDir; // Root directory for state (used for testing)
+ bool IsDebug = false;
+ bool IsTest = false;
+ bool IsDedicated = false; // Indicates a dedicated/shared instance, with larger resource requirements
+ int BasePort = 1337; // Service listen port (used for both UDP and TCP)
+ int OwnerPid = 0; // Parent process id (zero for standalone)
+ std::string ChildId; // Id assigned by parent process (used for lifetime management)
+ std::string LogId; // Id for tagging log output
+ std::filesystem::path DataDir; // Root directory for state (used for testing)
};
struct ZenUpstreamJupiterConfig
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp
index c9f74daa4..2545ed7a2 100644
--- a/zenserver/zenserver.cpp
+++ b/zenserver/zenserver.cpp
@@ -310,6 +310,7 @@ public:
void Cleanup() { spdlog::info(ZEN_APP_NAME " cleaning up"); }
+ void SetDedicatedMode(bool State) { m_IsDedicatedMode = State; }
void SetTestMode(bool State) { m_TestMode = State; }
void SetDataRoot(std::filesystem::path Root) { m_DataRoot = Root; }
@@ -359,7 +360,8 @@ public:
}
private:
- bool m_TestMode = false;
+ bool m_IsDedicatedMode = false;
+ bool m_TestMode = false;
std::filesystem::path m_DataRoot;
std::jthread m_IoRunner;
asio::io_context m_IoContext;
@@ -442,6 +444,7 @@ main(int argc, char* argv[])
ZenServer Server;
Server.SetDataRoot(GlobalOptions.DataDir);
Server.SetTestMode(GlobalOptions.IsTest);
+ Server.SetDedicatedMode(GlobalOptions.IsDedicated);
Server.Initialize(ServiceConfig, GlobalOptions.BasePort, GlobalOptions.OwnerPid);
// Monitor shutdown signals