aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenserver/main.cpp')
-rw-r--r--src/zenserver/main.cpp39
1 files changed, 32 insertions, 7 deletions
diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp
index 69cc2bbf5..be2cdcc2d 100644
--- a/src/zenserver/main.cpp
+++ b/src/zenserver/main.cpp
@@ -39,6 +39,7 @@ ZEN_THIRD_PARTY_INCLUDES_END
#if ZEN_WITH_TESTS
# define ZEN_TEST_WITH_RUNNER 1
# include <zencore/testing.h>
+# include <zenutil/zenutil.h>
#endif
#include <memory>
@@ -198,13 +199,15 @@ ZenEntryPoint::Run()
ShutdownThread.reset(new std::thread{[&] {
SetCurrentThreadName("shutdown_monitor");
- ZEN_INFO("shutdown monitor thread waiting for shutdown signal '{}'", ShutdownEventName);
+ ZEN_INFO("shutdown monitor thread waiting for shutdown signal '{}' for process {}",
+ ShutdownEventName,
+ zen::GetCurrentProcessId());
if (ShutdownEvent->Wait())
{
if (!IsApplicationExitRequested())
{
- ZEN_INFO("shutdown signal received");
+ ZEN_INFO("shutdown signal for pid {} received", zen::GetCurrentProcessId());
Server.RequestExit(0);
}
}
@@ -244,7 +247,7 @@ ZenEntryPoint::Run()
}
catch (std::exception& e)
{
- ZEN_CRITICAL("Caught exception in main: {}", e.what());
+ ZEN_CRITICAL("Caught exception in main for process {}: {}", zen::GetCurrentProcessId(), e.what());
if (!IsApplicationExitRequested())
{
RequestApplicationExit(1);
@@ -293,6 +296,7 @@ test_main(int argc, char** argv)
zen::zencore_forcelinktests();
zen::zenhttp_forcelinktests();
zen::zenstore_forcelinktests();
+ zen::zenutil_forcelinktests();
zen::z$_forcelink();
zen::z$service_forcelink();
@@ -334,9 +338,24 @@ main(int argc, char* argv[])
ZenServerOptions ServerOptions;
ParseCliOptions(argc, argv, ServerOptions);
+ std::string_view DeleteReason;
+
if (ServerOptions.IsCleanStart)
{
- DeleteDirectories(ServerOptions.DataDir);
+ DeleteReason = "clean start requested"sv;
+ }
+ else if (!ServerOptions.BaseSnapshotDir.empty())
+ {
+ DeleteReason = "will initialize state from base snapshot"sv;
+ }
+
+ if (!DeleteReason.empty())
+ {
+ if (std::filesystem::exists(ServerOptions.DataDir))
+ {
+ ZEN_CONSOLE_INFO("deleting files from '{}' ({})", ServerOptions.DataDir, DeleteReason);
+ DeleteDirectories(ServerOptions.DataDir);
+ }
}
if (!std::filesystem::exists(ServerOptions.DataDir))
@@ -345,18 +364,24 @@ main(int argc, char* argv[])
std::filesystem::create_directories(ServerOptions.DataDir);
}
+ if (!ServerOptions.BaseSnapshotDir.empty())
+ {
+ ZEN_CONSOLE_INFO("copying snapshot from '{}' into '{}", ServerOptions.BaseSnapshotDir, ServerOptions.DataDir);
+ CopyTree(ServerOptions.BaseSnapshotDir, ServerOptions.DataDir, {.EnableClone = true});
+ }
+
#if ZEN_WITH_TRACE
if (ServerOptions.TraceHost.size())
{
- TraceStart(ServerOptions.TraceHost.c_str(), TraceType::Network);
+ TraceStart("zenserver", ServerOptions.TraceHost.c_str(), TraceType::Network);
}
else if (ServerOptions.TraceFile.size())
{
- TraceStart(ServerOptions.TraceFile.c_str(), TraceType::File);
+ TraceStart("zenserver", ServerOptions.TraceFile.c_str(), TraceType::File);
}
else
{
- TraceInit();
+ TraceInit("zenserver");
}
atexit(TraceShutdown);
#endif // ZEN_WITH_TRACE