aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/main.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-02-18 11:28:03 +0100
committerGitHub Enterprise <[email protected]>2026-02-18 11:28:03 +0100
commit149a5c2faa8d59290b8b44717e504532e906aae2 (patch)
tree9c875f1fd89f65f939bf8f6ef67b506565be845c /src/zenserver/main.cpp
parentadd selective request logging support to http.sys (#762) (diff)
downloadzen-149a5c2faa8d59290b8b44717e504532e906aae2.tar.xz
zen-149a5c2faa8d59290b8b44717e504532e906aae2.zip
structured compute basics (#714)
this change adds the `zencompute` component, which can be used to distribute work dispatched from UE using the DDB (Derived Data Build) APIs via zenserver this change also adds a distinct zenserver compute mode (`zenserver compute`) which is intended to be used for leaf compute nodes to exercise the compute functionality without directly involving UE, a `zen exec` subcommand is also added, which can be used to feed replays through the system all new functionality is considered *experimental* and disabled by default at this time, behind the `zencompute` option in xmake config
Diffstat (limited to 'src/zenserver/main.cpp')
-rw-r--r--src/zenserver/main.cpp55
1 files changed, 50 insertions, 5 deletions
diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp
index 1a929b026..ee783d2a6 100644
--- a/src/zenserver/main.cpp
+++ b/src/zenserver/main.cpp
@@ -23,6 +23,9 @@
#include <zenutil/service.h>
#include "diag/logging.h"
+
+#include "compute/computeserver.h"
+
#include "storage/storageconfig.h"
#include "storage/zenstorageserver.h"
@@ -61,11 +64,19 @@ namespace zen {
#if ZEN_PLATFORM_WINDOWS
-template<class T>
+/** Windows Service wrapper for Zen servers
+ *
+ * This class wraps a Zen server main entry point (the Main template parameter)
+ * into a Windows Service by implementing the WindowsService interface.
+ *
+ * The Main type needs to implement the virtual functions from the ZenServerMain
+ * base class, which provides the actual server logic.
+ */
+template<class Main>
class ZenWindowsService : public WindowsService
{
public:
- ZenWindowsService(typename T::Config& ServerOptions) : m_EntryPoint(ServerOptions) {}
+ ZenWindowsService(typename Main::Config& ServerOptions) : m_EntryPoint(ServerOptions) {}
ZenWindowsService(const ZenWindowsService&) = delete;
ZenWindowsService& operator=(const ZenWindowsService&) = delete;
@@ -73,7 +84,7 @@ public:
virtual int Run() override { return m_EntryPoint.Run(); }
private:
- T m_EntryPoint;
+ Main m_EntryPoint;
};
#endif // ZEN_PLATFORM_WINDOWS
@@ -84,6 +95,23 @@ private:
namespace zen {
+/** Application main entry point template
+ *
+ * This function handles common application startup tasks while allowing
+ * different server types to be plugged in via the Main template parameter.
+ *
+ * On Windows, this function also handles platform-specific service
+ * installation and uninstallation.
+ *
+ * The Main type needs to implement the virtual functions from the ZenServerMain
+ * base class, which provides the actual server logic.
+ *
+ * The Main type is also expected to provide the following members:
+ *
+ * typedef Config -- Server configuration type, derived from ZenServerConfig
+ * typedef Configurator -- Server configuration handler type, implements ZenServerConfiguratorBase
+ *
+ */
template<class Main>
int
AppMain(int argc, char* argv[])
@@ -241,7 +269,12 @@ main(int argc, char* argv[])
auto _ = zen::MakeGuard([] {
// Allow some time for worker threads to unravel, in an effort
- // to prevent shutdown races in TLS object destruction
+ // to prevent shutdown races in TLS object destruction, mainly due to
+ // threads which we don't directly control (Windows thread pool) and
+ // therefore can't join.
+ //
+ // This isn't a great solution, but for now it seems to help reduce
+ // shutdown crashes observed in some situations.
WaitForThreads(1000);
});
@@ -249,6 +282,7 @@ main(int argc, char* argv[])
{
kHub,
kStore,
+ kCompute,
kTest
} ServerMode = kStore;
@@ -258,10 +292,14 @@ main(int argc, char* argv[])
{
ServerMode = kHub;
}
- else if (argv[1] == "store"sv)
+ else if ((argv[1] == "store"sv) || (argv[1] == "storage"sv))
{
ServerMode = kStore;
}
+ else if (argv[1] == "compute"sv)
+ {
+ ServerMode = kCompute;
+ }
else if (argv[1] == "test"sv)
{
ServerMode = kTest;
@@ -280,6 +318,13 @@ main(int argc, char* argv[])
break;
case kHub:
return AppMain<ZenHubServerMain>(argc, argv);
+ case kCompute:
+#if ZEN_WITH_COMPUTE_SERVICES
+ return AppMain<ZenComputeServerMain>(argc, argv);
+#else
+ fprintf(stderr, "compute services are not compiled in!\n");
+ exit(5);
+#endif
default:
case kStore:
return AppMain<ZenStorageServerMain>(argc, argv);