aboutsummaryrefslogtreecommitdiff
path: root/zenserver/zenserver.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-08-09 21:09:36 +0200
committerStefan Boberg <[email protected]>2021-08-09 21:09:36 +0200
commita7dc3e6c404a4f69ccc17aa2baa3cd24c87cf65b (patch)
tree790fb1286fc3bacd12dd56e684ff9aeeb4aaf67c /zenserver/zenserver.cpp
parentBasic implementation of 'down' command (diff)
downloadzen-a7dc3e6c404a4f69ccc17aa2baa3cd24c87cf65b.tar.xz
zen-a7dc3e6c404a4f69ccc17aa2baa3cd24c87cf65b.zip
Changed logic so that the shutdown monitoring thread is spun up in non-test modes as well
Diffstat (limited to 'zenserver/zenserver.cpp')
-rw-r--r--zenserver/zenserver.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp
index 56b6c793f..eb8df2b23 100644
--- a/zenserver/zenserver.cpp
+++ b/zenserver/zenserver.cpp
@@ -308,6 +308,15 @@ main(int argc, char* argv[])
Server.SetTestMode(GlobalOptions.IsTest);
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);
+ ShutdownEvent->Wait();
+ spdlog::info("shutdown signal received");
+ Server.RequestExit(0);
+ }});
+
// If we have a parent process, establish the mechanisms we need
// to be able to communicate with the parent
@@ -315,23 +324,13 @@ main(int argc, char* argv[])
{
zen::NamedEvent ParentEvent{GlobalOptions.ChildId};
ParentEvent.Set();
-
- ShutdownThread.reset(new std::thread{[&] {
- spdlog::info("shutdown monitor thread waiting for shutdown signal '{}'", ShutdownEventName);
- ShutdownEvent->Wait();
- spdlog::info("shutdown signal received");
- Server.RequestExit(0);
- }});
}
Server.Run();
Server.Cleanup();
- if (ShutdownEvent)
- {
- ShutdownEvent->Set();
- ShutdownThread->join();
- }
+ ShutdownEvent->Set();
+ ShutdownThread->join();
}
catch (std::exception& e)
{