aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/zenserver.cpp
diff options
context:
space:
mode:
authorLiam Mitchell <[email protected]>2026-03-09 18:25:30 -0700
committerLiam Mitchell <[email protected]>2026-03-09 18:25:30 -0700
commit57c1683b2935c834250b73eb506319ed67946160 (patch)
tree1fc8f237010b26e65659b731fe6f6eae30422f5c /src/zenserver/zenserver.cpp
parentAllow external OidcToken executable to be specified unless disabled via comma... (diff)
parentreduce lock time for project store gc precache and gc validate (#750) (diff)
downloadzen-57c1683b2935c834250b73eb506319ed67946160.tar.xz
zen-57c1683b2935c834250b73eb506319ed67946160.zip
Merge branch 'main' into lm/oidctoken-exe-path
Diffstat (limited to 'src/zenserver/zenserver.cpp')
-rw-r--r--src/zenserver/zenserver.cpp86
1 files changed, 76 insertions, 10 deletions
diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp
index 08be5475a..04f60c73e 100644
--- a/src/zenserver/zenserver.cpp
+++ b/src/zenserver/zenserver.cpp
@@ -123,7 +123,9 @@ ZenServerBase::Initialize(const ZenServerConfig& ServerOptions, ZenServerState::
if (m_ServerMutex.Create(MutexName) == false)
{
- ThrowLastError(fmt::format("Failed to create mutex '{}'", MutexName).c_str());
+ std::error_code Ec = MakeErrorCodeFromLastError();
+ ZEN_WARN("Failed to create server mutex '{}'. Reason: '{}' ({})", MutexName, Ec.message(), Ec.value());
+ return -1;
}
EnqueueSigIntTimer();
@@ -150,6 +152,13 @@ ZenServerBase::Initialize(const ZenServerConfig& ServerOptions, ZenServerState::
EnqueueStatsReportingTimer();
}
+ m_HealthService.SetHealthInfo({.DataRoot = ServerOptions.DataDir,
+ .AbsLogPath = ServerOptions.AbsLogFile,
+ .HttpServerClass = std::string(ServerOptions.HttpConfig.ServerClass),
+ .BuildVersion = std::string(ZEN_CFG_VERSION_BUILD_STRING_FULL)});
+
+ LogSettingsSummary(ServerOptions);
+
return EffectiveBasePort;
}
@@ -162,24 +171,24 @@ ZenServerBase::Finalize()
}
void
-ZenServerBase::GetBuildOptions(StringBuilderBase& OutOptions)
+ZenServerBase::GetBuildOptions(StringBuilderBase& OutOptions, char Separator) const
{
ZEN_MEMSCOPE(GetZenserverTag());
OutOptions << "ZEN_ADDRESS_SANITIZER=" << (ZEN_ADDRESS_SANITIZER ? "1" : "0");
- OutOptions << ",";
+ OutOptions << Separator;
OutOptions << "ZEN_USE_SENTRY=" << (ZEN_USE_SENTRY ? "1" : "0");
- OutOptions << ",";
+ OutOptions << Separator;
OutOptions << "ZEN_WITH_TESTS=" << (ZEN_WITH_TESTS ? "1" : "0");
- OutOptions << ",";
+ OutOptions << Separator;
OutOptions << "ZEN_USE_MIMALLOC=" << (ZEN_USE_MIMALLOC ? "1" : "0");
- OutOptions << ",";
+ OutOptions << Separator;
OutOptions << "ZEN_USE_RPMALLOC=" << (ZEN_USE_RPMALLOC ? "1" : "0");
- OutOptions << ",";
+ OutOptions << Separator;
OutOptions << "ZEN_WITH_HTTPSYS=" << (ZEN_WITH_HTTPSYS ? "1" : "0");
- OutOptions << ",";
+ OutOptions << Separator;
OutOptions << "ZEN_WITH_MEMTRACK=" << (ZEN_WITH_MEMTRACK ? "1" : "0");
- OutOptions << ",";
+ OutOptions << Separator;
OutOptions << "ZEN_WITH_TRACE=" << (ZEN_WITH_TRACE ? "1" : "0");
}
@@ -373,6 +382,57 @@ ZenServerBase::HandleStatusRequest(HttpServerRequest& Request)
Request.WriteResponse(HttpResponseCode::OK, Cbo.Save());
}
+void
+ZenServerBase::LogSettingsSummary(const ZenServerConfig& ServerConfig)
+{
+ // clang-format off
+ std::list<std::pair<std::string_view, std::string>> Settings = {
+ {"DataDir"sv, ServerConfig.DataDir.string()},
+ {"AbsLogFile"sv, ServerConfig.AbsLogFile.string()},
+ {"SystemRootDir"sv, ServerConfig.SystemRootDir.string()},
+ {"ContentDir"sv, ServerConfig.ContentDir.string()},
+ {"BasePort"sv, fmt::to_string(ServerConfig.BasePort)},
+ {"IsDebug"sv, fmt::to_string(ServerConfig.IsDebug)},
+ {"IsCleanStart"sv, fmt::to_string(ServerConfig.IsCleanStart)},
+ {"IsPowerCycle"sv, fmt::to_string(ServerConfig.IsPowerCycle)},
+ {"IsTest"sv, fmt::to_string(ServerConfig.IsTest)},
+ {"Detach"sv, fmt::to_string(ServerConfig.Detach)},
+ {"NoConsoleOutput"sv, fmt::to_string(ServerConfig.NoConsoleOutput)},
+ {"QuietConsole"sv, fmt::to_string(ServerConfig.QuietConsole)},
+ {"CoreLimit"sv, fmt::to_string(ServerConfig.CoreLimit)},
+ {"IsDedicated"sv, fmt::to_string(ServerConfig.IsDedicated)},
+ {"ShouldCrash"sv, fmt::to_string(ServerConfig.ShouldCrash)},
+ {"ChildId"sv, ServerConfig.ChildId},
+ {"LogId"sv, ServerConfig.LogId},
+ {"Sentry DSN"sv, ServerConfig.SentryConfig.Dsn.empty() ? "not set" : ServerConfig.SentryConfig.Dsn},
+ {"Sentry Environment"sv, ServerConfig.SentryConfig.Environment},
+ {"Statsd Enabled"sv, fmt::to_string(ServerConfig.StatsConfig.Enabled)},
+ };
+ // clang-format on
+
+ if (ServerConfig.StatsConfig.Enabled)
+ {
+ Settings.emplace_back("Statsd Host", ServerConfig.StatsConfig.StatsdHost);
+ Settings.emplace_back("Statsd Port", fmt::to_string(ServerConfig.StatsConfig.StatsdPort));
+ }
+
+ size_t MaxWidth = 0;
+ for (const auto& Setting : Settings)
+ {
+ MaxWidth = std::max(MaxWidth, Setting.first.size());
+ }
+
+ ZEN_INFO("Server settings summary:");
+
+ for (const auto& Setting : Settings)
+ {
+ if (!Setting.second.empty())
+ {
+ ZEN_INFO(" {:<{}} : {}", Setting.first, MaxWidth, Setting.second);
+ }
+ }
+}
+
//////////////////////////////////////////////////////////////////////////
ZenServerMain::ZenServerMain(ZenServerConfig& ServerOptions) : m_ServerOptions(ServerOptions)
@@ -383,6 +443,12 @@ ZenServerMain::~ZenServerMain()
{
}
+void
+ZenServerMain::InitializeLogging()
+{
+ InitializeServerLogging(m_ServerOptions, /* WithCacheService */ false);
+}
+
int
ZenServerMain::Run()
{
@@ -510,7 +576,7 @@ ZenServerMain::Run()
}
}
- InitializeServerLogging(m_ServerOptions, /* WithCacheService */ true);
+ InitializeLogging();
ZEN_INFO("Command line: {}", m_ServerOptions.CommandLine);