diff options
| author | Stefan Boberg <[email protected]> | 2021-10-14 19:07:14 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-10-14 19:07:14 +0200 |
| commit | 2b71d6a8d57c773bc7734b253a1ffd1e47162184 (patch) | |
| tree | c0c70f9f2f8b9dc895080aac9f7de1140c56ebf0 /zenserver | |
| parent | Merge branch 'main' of https://github.com/EpicGames/zen (diff) | |
| download | zen-2b71d6a8d57c773bc7734b253a1ffd1e47162184.tar.xz zen-2b71d6a8d57c773bc7734b253a1ffd1e47162184.zip | |
asio HTTP implementation (#23)
asio-based HTTP implementation
Diffstat (limited to 'zenserver')
| -rw-r--r-- | zenserver/config.cpp | 13 | ||||
| -rw-r--r-- | zenserver/config.h | 3 | ||||
| -rw-r--r-- | zenserver/xmake.lua | 2 | ||||
| -rw-r--r-- | zenserver/zenserver.cpp | 6 |
4 files changed, 19 insertions, 5 deletions
diff --git a/zenserver/config.cpp b/zenserver/config.cpp index df3259542..8d7254ae1 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -81,6 +81,12 @@ ParseUpstreamCachePolicy(std::string_view Options) void ParseGlobalCliOptions(int argc, char* argv[], ZenServerOptions& GlobalOptions, ZenServiceConfig& ServiceConfig) { +#if ZEN_WITH_HTTPSYS + const char* DefaultHttp = "httpsys"; +#else + const char* DefaultHttp = "asio"; +#endif + cxxopts::Options options("zenserver", "Zen Server"); options.add_options()("dedicated", "Enable dedicated server mode", @@ -118,6 +124,13 @@ ParseGlobalCliOptions(int argc, char* argv[], ZenServerOptions& GlobalOptions, Z #endif options.add_option("network", + "", + "http", + "Select HTTP server implementation (asio|httpsys|null)", + cxxopts::value<std::string>(GlobalOptions.HttpServerClass)->default_value(DefaultHttp), + "<http class>"); + + options.add_option("network", "p", "port", "Select HTTP port", diff --git a/zenserver/config.h b/zenserver/config.h index 405e22739..eaafc31bb 100644 --- a/zenserver/config.h +++ b/zenserver/config.h @@ -18,7 +18,8 @@ struct ZenServerOptions std::string LogId; // Id for tagging log output 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; + std::string HttpServerClass; // Choice of HTTP server implementation + std::filesystem::path AbsLogFile; // Absolute path to main log file }; struct ZenUpstreamJupiterConfig diff --git a/zenserver/xmake.lua b/zenserver/xmake.lua index fb1ba651d..bba9b6ba5 100644 --- a/zenserver/xmake.lua +++ b/zenserver/xmake.lua @@ -26,7 +26,7 @@ target("zenserver") "vcpkg::lua", "vcpkg::asio", "vcpkg::json11", - "vcpkg::uwebsockets", "vcpkg::usockets", "vcpkg::libuv" + "vcpkg::http-parser" ) add_packages( diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index 18c59636d..1fddec437 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -108,7 +108,7 @@ using namespace std::literals; class ZenServer : public IHttpStatusProvider { public: - void Initialize(ZenServiceConfig& ServiceConfig, int BasePort, int ParentPid, ZenServerState::ZenServerEntry* ServerEntry) + void Initialize(ZenServiceConfig& ServiceConfig, std::string_view HttpServerClass, int BasePort, int ParentPid, ZenServerState::ZenServerEntry* ServerEntry) { using namespace fmt::literals; @@ -146,7 +146,7 @@ public: // Ok so now we're configured, let's kick things off - m_Http = zen::CreateHttpServer(); + m_Http = zen::CreateHttpServer(HttpServerClass); m_Http->Initialize(BasePort); m_Http->RegisterService(m_HealthService); m_Http->RegisterService(m_StatsService); @@ -636,7 +636,7 @@ ZenWindowsService::Run() Server.SetContentRoot(GlobalOptions.ContentDir); Server.SetTestMode(GlobalOptions.IsTest); Server.SetDedicatedMode(GlobalOptions.IsDedicated); - Server.Initialize(ServiceConfig, GlobalOptions.BasePort, GlobalOptions.OwnerPid, Entry); + Server.Initialize(ServiceConfig, GlobalOptions.HttpServerClass, GlobalOptions.BasePort, GlobalOptions.OwnerPid, Entry); // Monitor shutdown signals |