diff options
Diffstat (limited to 'src/zenserver/zenserver.h')
| -rw-r--r-- | src/zenserver/zenserver.h | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/src/zenserver/zenserver.h b/src/zenserver/zenserver.h index ab7122fcc..c06093f0d 100644 --- a/src/zenserver/zenserver.h +++ b/src/zenserver/zenserver.h @@ -3,11 +3,13 @@ #pragma once #include <zencore/basicfile.h> +#include <zencore/system.h> #include <zenhttp/httpserver.h> #include <zenhttp/httpstats.h> #include <zenhttp/httpstatus.h> #include <zenutil/zenserverprocess.h> +#include <atomic> #include <memory> #include <string_view> #include "config/config.h" @@ -43,11 +45,18 @@ public: void SetIsReadyFunc(std::function<void()>&& IsReadyFunc) { m_IsReadyFunc = std::move(IsReadyFunc); } + void SetDataRoot(std::filesystem::path Root) { m_DataRoot = Root; } + void SetContentRoot(std::filesystem::path Root) { m_ContentRoot = Root; } + void SetDedicatedMode(bool State) { m_IsDedicatedMode = State; } + void SetTestMode(bool State) { m_TestMode = State; } + protected: int Initialize(const ZenServerConfig& ServerOptions, ZenServerState::ZenServerEntry* ServerEntry); void Finalize(); + void ShutdownServices(); void GetBuildOptions(StringBuilderBase& OutOptions, char Separator = ',') const; - void LogSettingsSummary(const ZenServerConfig& ServerConfig); + static std::vector<std::pair<std::string_view, std::string>> BuildSettingsList(const ZenServerConfig& ServerConfig); + void LogSettingsSummary(const ZenServerConfig& ServerConfig); protected: NamedMutex m_ServerMutex; @@ -55,6 +64,10 @@ protected: bool m_UseSentry = false; bool m_IsPowerCycle = false; + bool m_IsDedicatedMode = false; + bool m_TestMode = false; + bool m_DebugOptionForcedCrash = false; + std::thread m_IoRunner; asio::io_context m_IoContext; void EnsureIoRunner(); @@ -64,17 +77,26 @@ protected: kInitializing, kRunning, kShuttingDown - } m_CurrentState = kInitializing; + }; + std::atomic<ServerState> m_CurrentState = kInitializing; - inline void SetNewState(ServerState NewState) { m_CurrentState = NewState; } + inline void SetNewState(ServerState NewState) { m_CurrentState.store(NewState, std::memory_order_relaxed); } static std::string_view ToString(ServerState Value); std::function<void()> m_IsReadyFunc; void OnReady(); - Ref<HttpServer> m_Http; - HttpHealthService m_HealthService; - HttpStatusService m_StatusService; + std::filesystem::path m_DataRoot; // Root directory for server state + std::filesystem::path m_ContentRoot; // Root directory for frontend content + + Ref<HttpServer> m_Http; + + std::unique_ptr<IHttpRequestFilter> m_HttpRequestFilter; + + HttpHealthService m_HealthService; + HttpStatsService m_StatsService{m_IoContext}; + HttpStatusService m_StatusService; + SystemMetricsTracker m_MetricsTracker; // Stats reporting @@ -107,8 +129,10 @@ protected: // IHttpStatusProvider virtual void HandleStatusRequest(HttpServerRequest& Request) override; -}; +private: + void InitializeSecuritySettings(const ZenServerConfig& ServerOptions); +}; class ZenServerMain { public: |