diff options
| author | Dan Engelbrecht <[email protected]> | 2023-09-14 03:54:57 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-09-14 09:54:57 +0200 |
| commit | e0da430c424192c24f5089ceb97f37062349e9ef (patch) | |
| tree | 2d83811f16839c1133a38b8a05c5ef1074a3701f /src/zenserver | |
| parent | disable access logging on shared instances (#403) (diff) | |
| download | zen-e0da430c424192c24f5089ceb97f37062349e9ef.tar.xz zen-e0da430c424192c24f5089ceb97f37062349e9ef.zip | |
http and httpsys config options (#401)
* Added `--http-threads`, `--httpsys-async-work-threads`, `--httpsys-enable-request-logging` and `--httpsys-enable-async-response` command line options to zenserver
* remove unused CreateHttpSysServer
Diffstat (limited to 'src/zenserver')
| -rw-r--r-- | src/zenserver/config.cpp | 43 | ||||
| -rw-r--r-- | src/zenserver/config.h | 3 | ||||
| -rw-r--r-- | src/zenserver/zenserver.cpp | 4 |
3 files changed, 45 insertions, 5 deletions
diff --git a/src/zenserver/config.cpp b/src/zenserver/config.cpp index 7ec3a0cee..64acdfe73 100644 --- a/src/zenserver/config.cpp +++ b/src/zenserver/config.cpp @@ -793,11 +793,22 @@ ParseConfigFile(const std::filesystem::path& Path, LuaOptions.AddOption("server.objectstore.buckets"sv, ServerOptions.ObjectStoreConfig); ////// network - LuaOptions.AddOption("network.httpserverclass"sv, ServerOptions.HttpServerClass, "http"sv); + LuaOptions.AddOption("network.httpserverclass"sv, ServerOptions.HttpServerConfig.ServerClass, "http"sv); + LuaOptions.AddOption("network.httpserverthreads"sv, ServerOptions.HttpServerConfig.ThreadCount, "http-threads"sv); LuaOptions.AddOption("network.port"sv, ServerOptions.BasePort, "port"sv); LuaOptions.AddOption("network.websocket.port"sv, ServerOptions.WebSocketPort, "websocket-port"sv); LuaOptions.AddOption("network.websocket.threadcount"sv, ServerOptions.WebSocketThreads, "websocket-threads"sv); + LuaOptions.AddOption("network.httpsys.async.workthreads"sv, + ServerOptions.HttpServerConfig.HttpSys.AsyncWorkThreadCount, + "httpsys-async-work-threads"sv); + LuaOptions.AddOption("network.httpsys.async.response"sv, + ServerOptions.HttpServerConfig.HttpSys.IsAsyncResponseEnabled, + "httpsys-enable-async-response"sv); + LuaOptions.AddOption("network.httpsys.requestlogging"sv, + ServerOptions.HttpServerConfig.HttpSys.IsRequestLoggingEnabled, + "httpsys-enable-request-logging"sv); + ////// trace LuaOptions.AddOption("trace.host"sv, ServerOptions.TraceHost, "tracehost"sv); LuaOptions.AddOption("trace.file"sv, ServerOptions.TraceFile, "tracefile"sv); @@ -1037,10 +1048,17 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) "", "http", "Select HTTP server implementation (asio|httpsys|null)", - cxxopts::value<std::string>(ServerOptions.HttpServerClass)->default_value(DefaultHttp), + cxxopts::value<std::string>(ServerOptions.HttpServerConfig.ServerClass)->default_value(DefaultHttp), "<http class>"); options.add_option("network", + "", + "http-threads", + "Number of http server connection threads", + cxxopts::value<unsigned int>(ServerOptions.HttpServerConfig.ThreadCount), + "<http threads>"); + + options.add_option("network", "p", "port", "Select HTTP port", @@ -1061,6 +1079,27 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) cxxopts::value<int>(ServerOptions.WebSocketThreads)->default_value("0"), ""); + options.add_option("httpsys", + "", + "httpsys-async-work-threads", + "Number of HttpSys async worker threads", + cxxopts::value<unsigned int>(ServerOptions.HttpServerConfig.HttpSys.AsyncWorkThreadCount), + "<httpsys workthreads>"); + + options.add_option("httpsys", + "", + "httpsys-enable-async-response", + "Enables Httpsys async response", + cxxopts::value<bool>(ServerOptions.HttpServerConfig.HttpSys.IsAsyncResponseEnabled)->default_value("true"), + "<httpsys async response>"); + + options.add_option("httpsys", + "", + "httpsys-enable-request-logging", + "Enables Httpsys request logging", + cxxopts::value<bool>(ServerOptions.HttpServerConfig.HttpSys.IsRequestLoggingEnabled), + "<httpsys request logging>"); + #if ZEN_WITH_TRACE options.add_option("ue-trace", "", diff --git a/src/zenserver/config.h b/src/zenserver/config.h index 0bb20aba4..f5438489d 100644 --- a/src/zenserver/config.h +++ b/src/zenserver/config.h @@ -3,6 +3,7 @@ #pragma once #include <zencore/zencore.h> +#include <zenhttp/httpserver.h> #include <filesystem> #include <string> #include <vector> @@ -120,13 +121,13 @@ struct ZenServerOptions ZenGcConfig GcConfig; ZenAuthConfig AuthConfig; ZenObjectStoreConfig ObjectStoreConfig; + zen::HttpServerConfig HttpServerConfig; std::filesystem::path DataDir; // Root directory for state (used for testing) std::filesystem::path ContentDir; // Root directory for serving frontend content (experimental) std::filesystem::path AbsLogFile; // Absolute path to main log file std::filesystem::path ConfigFile; // Path to Lua config file std::string ChildId; // Id assigned by parent process (used for lifetime management) std::string LogId; // Id for tagging log output - std::string HttpServerClass; // Choice of HTTP server implementation std::string EncryptionKey; // 256 bit AES encryption key std::string EncryptionIV; // 128 bit AES initialization vector int BasePort = 1337; // Service listen port (used for both UDP and TCP) diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp index 8056b6506..1baedd6eb 100644 --- a/src/zenserver/zenserver.cpp +++ b/src/zenserver/zenserver.cpp @@ -276,12 +276,12 @@ public: m_HealthService.SetHealthInfo({.DataRoot = m_DataRoot, .AbsLogPath = ServerOptions.AbsLogFile, - .HttpServerClass = std::string(ServerOptions.HttpServerClass), + .HttpServerClass = std::string(ServerOptions.HttpServerConfig.ServerClass), .BuildVersion = std::string(ZEN_CFG_VERSION_BUILD_STRING_FULL)}); // Ok so now we're configured, let's kick things off - m_Http = zen::CreateHttpServer(ServerOptions.HttpServerClass); + m_Http = zen::CreateHttpServer(ServerOptions.HttpServerConfig); int EffectiveBasePort = m_Http->Initialize(ServerOptions.BasePort); if (ServerOptions.WebSocketPort != 0) |