aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/zenserver.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenserver/zenserver.h')
-rw-r--r--src/zenserver/zenserver.h52
1 files changed, 38 insertions, 14 deletions
diff --git a/src/zenserver/zenserver.h b/src/zenserver/zenserver.h
index 5a8a079c0..995ff054f 100644
--- a/src/zenserver/zenserver.h
+++ b/src/zenserver/zenserver.h
@@ -3,11 +3,14 @@
#pragma once
#include <zencore/basicfile.h>
+#include <zencore/logging/sink.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"
@@ -25,6 +28,8 @@ ZEN_THIRD_PARTY_INCLUDES_END
namespace zen {
+class HttpSessionsService;
+class SessionsService;
struct FLLMTag;
extern const FLLMTag& GetZenserverTag();
@@ -43,16 +48,22 @@ 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; }
+ 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 SetAllowPortProbing(bool State) { m_AllowPortProbing = State; }
+ void SetServerMode(std::string_view Mode) { m_ServerMode = Mode; }
+ const std::string& GetServerMode() const { return m_ServerMode; }
+ void SetTestMode(bool State) { m_TestMode = State; }
protected:
int Initialize(const ZenServerConfig& ServerOptions, ZenServerState::ZenServerEntry* ServerEntry);
void Finalize();
+ void ShutdownServices();
+ void StartSelfSession(std::string_view AppName);
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;
@@ -60,9 +71,12 @@ protected:
bool m_UseSentry = false;
bool m_IsPowerCycle = false;
- bool m_IsDedicatedMode = false;
- bool m_TestMode = false;
- bool m_DebugOptionForcedCrash = false;
+ bool m_IsDedicatedMode = false;
+ bool m_AllowPortProbing = true;
+ bool m_TestMode = false;
+ bool m_NoNetwork = false;
+ bool m_DebugOptionForcedCrash = false;
+ std::string m_ServerMode = "Server";
std::thread m_IoRunner;
asio::io_context m_IoContext;
@@ -73,9 +87,10 @@ 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;
@@ -88,8 +103,15 @@ protected:
std::unique_ptr<IHttpRequestFilter> m_HttpRequestFilter;
- HttpHealthService m_HealthService;
- HttpStatusService m_StatusService;
+ HttpHealthService m_HealthService;
+ HttpStatsService m_StatsService{m_IoContext};
+ HttpStatusService m_StatusService;
+ SystemMetricsTracker m_MetricsTracker;
+
+ // Sessions (shared by all derived servers)
+ std::unique_ptr<SessionsService> m_SessionsService;
+ std::unique_ptr<HttpSessionsService> m_HttpSessionsService;
+ logging::SinkPtr m_InProcSessionLogSink;
// Stats reporting
@@ -124,6 +146,7 @@ protected:
virtual void HandleStatusRequest(HttpServerRequest& Request) override;
private:
+ void InitializeSessions();
void InitializeSecuritySettings(const ZenServerConfig& ServerOptions);
};
class ZenServerMain
@@ -138,8 +161,9 @@ public:
ZenServerMain& operator=(const ZenServerMain&) = delete;
protected:
- ZenServerConfig& m_ServerOptions;
- LockFile m_LockFile;
+ ZenServerConfig& m_ServerOptions;
+ LockFile m_LockFile;
+ ZenServerInstanceInfo m_InstanceInfo;
virtual void InitializeLogging();
virtual void DoRun(ZenServerState::ZenServerEntry* Entry) = 0;