diff options
| author | Liam Mitchell <[email protected]> | 2025-08-22 16:12:38 -0700 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-08-22 16:12:38 -0700 |
| commit | 207c4a32612891711d9d69466b6dfc653428bb07 (patch) | |
| tree | d4b8de42a91ee3327b14fc0aa66c92bc3de46555 /src/zenserver/main.cpp | |
| parent | 5.6.18-pre0 (diff) | |
| parent | Move windows service utilities to zenutil and fix clang-format errors (diff) | |
| download | zen-207c4a32612891711d9d69466b6dfc653428bb07.tar.xz zen-207c4a32612891711d9d69466b6dfc653428bb07.zip | |
Merge pull request #139 from ue-foundation/de/zen-service-command
zen service command
Diffstat (limited to 'src/zenserver/main.cpp')
| -rw-r--r-- | src/zenserver/main.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp index 553562473..d8922f885 100644 --- a/src/zenserver/main.cpp +++ b/src/zenserver/main.cpp @@ -24,12 +24,14 @@ #include <zencore/memory/memorytrace.h> #include <zencore/memory/newdelete.h> +#include <zenutil/service.h> + #include "config.h" #include "diag/logging.h" #if ZEN_PLATFORM_WINDOWS # include <zencore/windows.h> -# include "windows/service.h" +# include <zenutil/windows/service.h> #endif ////////////////////////////////////////////////////////////////////////// @@ -91,6 +93,7 @@ ZenEntryPoint::ZenEntryPoint(ZenServerOptions& ServerOptions) : m_ServerOptions( int ZenEntryPoint::Run() { + ZEN_INFO("ZenEntryPoint::Run()"); zen::SetCurrentThreadName("main"); #if ZEN_USE_SENTRY @@ -288,6 +291,8 @@ ZenEntryPoint::Run() }}); auto CleanupShutdown = MakeGuard([&ShutdownEvent, &ShutdownThread] { + ReportServiceStatus(ServiceStatus::Stopping); + if (ShutdownEvent) { ShutdownEvent->Set(); @@ -303,6 +308,7 @@ ZenEntryPoint::Run() Server.SetIsReadyFunc([&] { m_LockFile.Update(MakeLockData(true), Ec); + ReportServiceStatus(ServiceStatus::Running); NotifyReady(); }); @@ -313,6 +319,14 @@ ZenEntryPoint::Run() ZEN_CRITICAL("Caught assert exception in main for process {}: {}", zen::GetCurrentProcessId(), AssertEx.FullDescription()); RequestApplicationExit(1); } + catch (const std::system_error& e) + { + ZEN_CRITICAL("Caught system error exception in main for process {}: {} ({})", + zen::GetCurrentProcessId(), + e.what(), + e.code().value()); + RequestApplicationExit(1); + } catch (const std::exception& e) { ZEN_CRITICAL("Caught exception in main for process {}: {}", zen::GetCurrentProcessId(), e.what()); @@ -321,6 +335,8 @@ ZenEntryPoint::Run() ShutdownServerLogging(); + ReportServiceStatus(ServiceStatus::Stopped); + return ApplicationExitCode(); } @@ -390,6 +406,10 @@ main(int argc, char* argv[]) signal(SIGINT, utils::SignalCallbackHandler); signal(SIGTERM, utils::SignalCallbackHandler); +#if ZEN_PLATFORM_LINUX + IgnoreChildSignals(); +#endif + try { ZenServerOptions ServerOptions; |