aboutsummaryrefslogtreecommitdiff
path: root/zenserver
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2021-10-15 16:04:56 +0200
committerMartin Ridgers <[email protected]>2021-10-15 16:04:56 +0200
commit402dfddf62d979319038801a926809e33839e096 (patch)
treee8a8e99c7f4718a5fcc363245cc19e16a41bea25 /zenserver
parentIf/def around Windows-only headers (diff)
parenthttpasio: Implemented support for specifying accept type via url suffix (diff)
downloadzen-402dfddf62d979319038801a926809e33839e096.tar.xz
zen-402dfddf62d979319038801a926809e33839e096.zip
Merged main
Diffstat (limited to 'zenserver')
-rw-r--r--zenserver/cache/structuredcachestore.cpp2
-rw-r--r--zenserver/config.cpp13
-rw-r--r--zenserver/config.h3
-rw-r--r--zenserver/xmake.lua2
-rw-r--r--zenserver/zenserver.cpp10
5 files changed, 24 insertions, 6 deletions
diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp
index ccd06b540..9f63699e5 100644
--- a/zenserver/cache/structuredcachestore.cpp
+++ b/zenserver/cache/structuredcachestore.cpp
@@ -728,7 +728,7 @@ ZenCacheDiskLayer::CacheBucket::PutStandaloneCacheValue(const IoHash& HashKey, c
if (Ec)
{
std::error_code InnerEc;
- const uint64_t ExistingFileSize = std::filesystem::file_size(FsPath, InnerEc);
+ const uint64_t ExistingFileSize = std::filesystem::file_size(FsPath, InnerEc);
if (!InnerEc && ExistingFileSize == Value.Value.Size())
{
diff --git a/zenserver/config.cpp b/zenserver/config.cpp
index 394201210..937598a64 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..a1cd01d33 100644
--- a/zenserver/zenserver.cpp
+++ b/zenserver/zenserver.cpp
@@ -108,7 +108,11 @@ 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 +150,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 +640,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