aboutsummaryrefslogtreecommitdiff
path: root/zenserver/zenserver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zenserver/zenserver.cpp')
-rw-r--r--zenserver/zenserver.cpp59
1 files changed, 31 insertions, 28 deletions
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp
index c9f74daa4..931fe062e 100644
--- a/zenserver/zenserver.cpp
+++ b/zenserver/zenserver.cpp
@@ -3,6 +3,7 @@
#include <zencore/filesystem.h>
#include <zencore/fmtutils.h>
#include <zencore/iobuffer.h>
+#include <zencore/logging.h>
#include <zencore/refcount.h>
#include <zencore/scopeguard.h>
#include <zencore/string.h>
@@ -17,7 +18,6 @@
#include <fmt/format.h>
#include <mimalloc-new-delete.h>
#include <mimalloc.h>
-#include <spdlog/spdlog.h>
#include <asio.hpp>
#include <exception>
#include <list>
@@ -88,7 +88,7 @@ public:
void Initialize(ZenServiceConfig& ServiceConfig, int BasePort, int ParentPid)
{
using namespace fmt::literals;
- spdlog::info(ZEN_APP_NAME " initializing");
+ ZEN_INFO(ZEN_APP_NAME " initializing");
m_DebugOptionForcedCrash = ServiceConfig.ShouldCrash;
@@ -98,11 +98,11 @@ public:
if (!m_Process.IsValid())
{
- spdlog::warn("Unable to initialize process handle for specified parent pid #{}", ParentPid);
+ ZEN_WARN("Unable to initialize process handle for specified parent pid #{}", ParentPid);
}
else
{
- spdlog::info("Using parent pid #{} to control process lifetime", ParentPid);
+ ZEN_INFO("Using parent pid #{} to control process lifetime", ParentPid);
}
}
@@ -117,7 +117,7 @@ public:
// Ok so now we're configured, let's kick things off
- spdlog::info("initializing storage");
+ ZEN_INFO("initializing storage");
zen::CasStoreConfiguration Config;
Config.RootDirectory = m_DataRoot / "cas";
@@ -126,13 +126,13 @@ public:
m_CidStore = std::make_unique<zen::CidStore>(*m_CasStore, m_DataRoot / "cid");
- spdlog::info("instantiating project service");
+ ZEN_INFO("instantiating project service");
m_ProjectStore = new zen::ProjectStore(*m_CasStore, m_DataRoot / "projects");
m_HttpProjectService.reset(new zen::HttpProjectService{*m_CasStore, m_ProjectStore});
m_LocalProjectService = zen::LocalProjectService::New(*m_CasStore, m_ProjectStore);
- spdlog::info("instantiating compute services");
+ ZEN_INFO("instantiating compute services");
std::filesystem::path SandboxDir = m_DataRoot / "exec" / "sandbox";
zen::CreateDirectories(SandboxDir);
@@ -147,7 +147,7 @@ public:
using namespace std::literals;
auto ValueOrDefault = [](std::string_view Value, std::string_view Default) { return Value.empty() ? Default : Value; };
- spdlog::info("instantiating structured cache service");
+ ZEN_INFO("instantiating structured cache service");
m_CacheStore = std::make_unique<ZenCacheStore>(*m_CasStore, m_DataRoot / "cache");
std::unique_ptr<zen::UpstreamCache> UpstreamCache;
@@ -201,12 +201,12 @@ public:
if (UpstreamCache->Initialize())
{
- spdlog::info("upstream cache active");
+ ZEN_INFO("upstream cache active");
}
else
{
UpstreamCache.reset();
- spdlog::info("NOT using upstream cache");
+ ZEN_INFO("NOT using upstream cache");
}
}
@@ -215,7 +215,7 @@ public:
}
else
{
- spdlog::info("NOT instantiating structured cache service");
+ ZEN_INFO("NOT instantiating structured cache service");
}
if (ServiceConfig.MeshEnabled)
@@ -224,7 +224,7 @@ public:
}
else
{
- spdlog::info("NOT starting mesh");
+ ZEN_INFO("NOT starting mesh");
}
m_Http = zen::CreateHttpServer();
@@ -261,7 +261,7 @@ public:
void StartMesh(int BasePort)
{
- spdlog::info("initializing mesh discovery");
+ ZEN_INFO("initializing mesh discovery");
m_ZenMesh.Start(uint16_t(BasePort));
}
@@ -274,15 +274,15 @@ public:
if (!m_TestMode)
{
- spdlog::info("__________ _________ __ ");
- spdlog::info("\\____ /____ ____ / _____// |_ ___________ ____ ");
- spdlog::info(" / // __ \\ / \\ \\_____ \\\\ __\\/ _ \\_ __ \\_/ __ \\ ");
- spdlog::info(" / /\\ ___/| | \\ / \\| | ( <_> ) | \\/\\ ___/ ");
- spdlog::info("/_______ \\___ >___| / /_______ /|__| \\____/|__| \\___ >");
- spdlog::info(" \\/ \\/ \\/ \\/ \\/ ");
+ ZEN_INFO("__________ _________ __ ");
+ ZEN_INFO("\\____ /____ ____ / _____// |_ ___________ ____ ");
+ ZEN_INFO(" / // __ \\ / \\ \\_____ \\\\ __\\/ _ \\_ __ \\_/ __ \\ ");
+ ZEN_INFO(" / /\\ ___/| | \\ / \\| | ( <_> ) | \\/\\ ___/ ");
+ ZEN_INFO("/_______ \\___ >___| / /_______ /|__| \\____/|__| \\___ >");
+ ZEN_INFO(" \\/ \\/ \\/ \\/ \\/ ");
}
- spdlog::info(ZEN_APP_NAME " now running");
+ ZEN_INFO(ZEN_APP_NAME " now running");
#if USE_SENTRY
sentry_clear_modulecache();
@@ -295,7 +295,7 @@ public:
m_Http->Run(m_TestMode);
- spdlog::info(ZEN_APP_NAME " exiting");
+ ZEN_INFO(ZEN_APP_NAME " exiting");
m_IoContext.stop();
@@ -308,8 +308,9 @@ public:
m_Http->RequestExit();
}
- void Cleanup() { spdlog::info(ZEN_APP_NAME " cleaning up"); }
+ void Cleanup() { ZEN_INFO(ZEN_APP_NAME " cleaning up"); }
+ void SetDedicatedMode(bool State) { m_IsDedicatedMode = State; }
void SetTestMode(bool State) { m_TestMode = State; }
void SetDataRoot(std::filesystem::path Root) { m_DataRoot = Root; }
@@ -337,7 +338,7 @@ public:
}
else
{
- spdlog::info(ZEN_APP_NAME " exiting since parent process id {} is gone", m_Process.Pid());
+ ZEN_INFO(ZEN_APP_NAME " exiting since parent process id {} is gone", m_Process.Pid());
RequestExit(0);
}
@@ -359,7 +360,8 @@ public:
}
private:
- bool m_TestMode = false;
+ bool m_IsDedicatedMode = false;
+ bool m_TestMode = false;
std::filesystem::path m_DataRoot;
std::jthread m_IoRunner;
asio::io_context m_IoContext;
@@ -413,7 +415,7 @@ main(int argc, char* argv[])
ParseServiceConfig(GlobalOptions.DataDir, /* out */ ServiceConfig);
- spdlog::info("zen cache server starting on port {}", GlobalOptions.BasePort);
+ ZEN_INFO("zen cache server starting on port {}", GlobalOptions.BasePort);
try
{
@@ -425,7 +427,7 @@ main(int argc, char* argv[])
{
// Instance already running for this port? Should double check pid
- spdlog::warn("Looks like there is already a process listening to this port (pid: {})", Entry->Pid);
+ ZEN_WARN("Looks like there is already a process listening to this port (pid: {})", Entry->Pid);
}
else
{
@@ -442,14 +444,15 @@ main(int argc, char* argv[])
ZenServer Server;
Server.SetDataRoot(GlobalOptions.DataDir);
Server.SetTestMode(GlobalOptions.IsTest);
+ Server.SetDedicatedMode(GlobalOptions.IsDedicated);
Server.Initialize(ServiceConfig, GlobalOptions.BasePort, GlobalOptions.OwnerPid);
// Monitor shutdown signals
ShutdownThread.reset(new std::thread{[&] {
- spdlog::info("shutdown monitor thread waiting for shutdown signal '{}'", ShutdownEventName);
+ ZEN_INFO("shutdown monitor thread waiting for shutdown signal '{}'", ShutdownEventName);
ShutdownEvent->Wait();
- spdlog::info("shutdown signal received");
+ ZEN_INFO("shutdown signal received");
Server.RequestExit(0);
}});