aboutsummaryrefslogtreecommitdiff
path: root/zenserver/zenserver.cpp
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2021-11-16 17:03:08 +0100
committerMartin Ridgers <[email protected]>2021-11-16 17:25:28 +0100
commit4f7207a1f961d88f3d825bd9faae02e664110301 (patch)
treea822a35ada3c14194d7f4941c0a8570f4aca8ccc /zenserver/zenserver.cpp
parentStubbed out NamedMutex (diff)
downloadzen-4f7207a1f961d88f3d825bd9faae02e664110301.tar.xz
zen-4f7207a1f961d88f3d825bd9faae02e664110301.zip
Separated Windows service scaffolding and the zenserver main loop
Diffstat (limited to 'zenserver/zenserver.cpp')
-rw-r--r--zenserver/zenserver.cpp65
1 files changed, 45 insertions, 20 deletions
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp
index 6ee8d1abb..ad4d1ba84 100644
--- a/zenserver/zenserver.cpp
+++ b/zenserver/zenserver.cpp
@@ -740,35 +740,31 @@ ZenServer::InitializeStructuredCache(ZenServiceConfig& ServiceConfig)
std::move(UpstreamCache)));
}
-} // namespace zen
-
-#if ZEN_PLATFORM_WINDOWS
+////////////////////////////////////////////////////////////////////////////////
-class ZenWindowsService : public WindowsService
+class ZenEntryPoint
{
public:
- ZenWindowsService(ZenServerOptions& GlobalOptions, ZenServiceConfig& ServiceConfig)
- : m_GlobalOptions(GlobalOptions)
- , m_ServiceConfig(ServiceConfig)
- {
- }
-
- ZenWindowsService(const ZenWindowsService&) = delete;
- ZenWindowsService& operator=(const ZenWindowsService&) = delete;
-
- virtual int Run() override;
+ ZenEntryPoint(ZenServerOptions& GlobalOptions, ZenServiceConfig& ServiceConfig);
+ ZenEntryPoint(const ZenEntryPoint&) = delete;
+ ZenEntryPoint& operator = (const ZenEntryPoint&) = delete;
+ int Run();
private:
- ZenServerOptions& m_GlobalOptions;
- ZenServiceConfig& m_ServiceConfig;
- zen::LockFile m_LockFile;
+ ZenServerOptions& m_GlobalOptions;
+ ZenServiceConfig& m_ServiceConfig;
+ zen::LockFile m_LockFile;
};
-int
-ZenWindowsService::Run()
+ZenEntryPoint::ZenEntryPoint(ZenServerOptions& GlobalOptions, ZenServiceConfig& ServiceConfig)
+: m_GlobalOptions(GlobalOptions)
+, m_ServiceConfig(ServiceConfig)
{
- using namespace zen;
+}
+int
+ZenEntryPoint::Run()
+{
#if USE_SENTRY
// Initialize sentry.io client
@@ -901,6 +897,35 @@ ZenWindowsService::Run()
return 0;
}
+} // namespace zen
+
+////////////////////////////////////////////////////////////////////////////////
+
+#if ZEN_PLATFORM_WINDOWS
+
+class ZenWindowsService : public WindowsService
+{
+public:
+ ZenWindowsService(ZenServerOptions& GlobalOptions, ZenServiceConfig& ServiceConfig)
+ : m_EntryPoint(GlobalOptions, ServiceConfig)
+ {
+ }
+
+ ZenWindowsService(const ZenWindowsService&) = delete;
+ ZenWindowsService& operator=(const ZenWindowsService&) = delete;
+
+ virtual int Run() override;
+
+private:
+ ZenEntryPoint m_EntryPoint;
+};
+
+int
+ZenWindowsService::Run()
+{
+ return m_EntryPoint.Run();
+}
+
#endif // ZEN_PLATFORM_WINDOWS
////////////////////////////////////////////////////////////////////////////////