diff options
| author | Liam Mitchell <[email protected]> | 2025-08-22 22:29:14 +0000 |
|---|---|---|
| committer | Liam Mitchell <[email protected]> | 2025-08-22 22:29:14 +0000 |
| commit | b905b6d1d94c2a09c268603935991ee3c018c700 (patch) | |
| tree | ebc8885ebb627b52edbf4ab36427a571916e8d9d /src | |
| parent | Remove workflow hacks for CI debugging (diff) | |
| download | zen-b905b6d1d94c2a09c268603935991ee3c018c700.tar.xz zen-b905b6d1d94c2a09c268603935991ee3c018c700.zip | |
Move ReportServiceStatus to zenutil and remove extraneous logging
Diffstat (limited to 'src')
| -rw-r--r-- | src/zenserver/main.cpp | 50 | ||||
| -rw-r--r-- | src/zenserver/xmake.lua | 8 | ||||
| -rw-r--r-- | src/zenutil/include/zenutil/service.h | 2 | ||||
| -rw-r--r-- | src/zenutil/service.cpp | 43 | ||||
| -rw-r--r-- | src/zenutil/xmake.lua | 8 |
5 files changed, 53 insertions, 58 deletions
diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp index 4ea4ee87e..e3c88f8bb 100644 --- a/src/zenserver/main.cpp +++ b/src/zenserver/main.cpp @@ -34,12 +34,6 @@ # include "windows/service.h" #endif -#if ZEN_PLATFORM_LINUX -ZEN_THIRD_PARTY_INCLUDES_START -# include <systemd/sd-daemon.h> -ZEN_THIRD_PARTY_INCLUDES_END -#endif - ////////////////////////////////////////////////////////////////////////// // We don't have any doctest code in this file but this is needed to bring // in some shared code into the executable @@ -96,43 +90,6 @@ ZenEntryPoint::ZenEntryPoint(ZenServerOptions& ServerOptions) : m_ServerOptions( { } -void -ReportServiceStatus(ServiceStatus Status) -{ -#if ZEN_PLATFORM_WINDOWS - switch (Status) - { - case ServiceStatus::Starting: - ReportSvcStatus(SERVICE_START_PENDING, NO_ERROR, 3000); - break; - case ServiceStatus::Running: - ReportSvcStatus(SERVICE_RUNNING, NO_ERROR, 0); - break; - case ServiceStatus::Stopping: - ReportSvcStatus(SERVICE_STOP_PENDING, NO_ERROR, 0); - break; - case ServiceStatus::Stopped: - ReportSvcStatus(SERVICE_STOPPED, (DWORD)ApplicationExitCode(), 0); - break; - default: - break; - } -#elif ZEN_PLATFORM_LINUX - switch (Status) - { - case ServiceStatus::Running: - sd_notify(0, "READY=1"); - break; - case ServiceStatus::Stopping: - sd_notify(0, "STOPPING=1"); - break; - case ServiceStatus::Stopped: - sd_notifyf(0, "EXIT_STATUS=%d", ApplicationExitCode()); - break; - } -#endif - (void)Status; -} int ZenEntryPoint::Run() @@ -160,11 +117,8 @@ ZenEntryPoint::Run() try { // Mutual exclusion and synchronization - ZEN_INFO("ZenServerState ServerState"); ZenServerState ServerState; - ZEN_INFO("ServerState.Initialize()"); ServerState.Initialize(); - ZEN_INFO("ServerState.Sweep()"); ServerState.Sweep(); auto NotifyReady = [&] { @@ -238,8 +192,6 @@ ZenEntryPoint::Run() } } - ZEN_INFO("Preparing lock file"); - std::error_code Ec; std::filesystem::path LockFilePath = m_ServerOptions.DataDir / ".lock"; @@ -253,7 +205,6 @@ ZenEntryPoint::Run() .ExecutablePath = GetRunningExecutablePath()}); }; - ZEN_INFO("m_LockFile.Create"); m_LockFile.Create(LockFilePath, MakeLockData(false), Ec); if (Ec) @@ -269,7 +220,6 @@ ZenEntryPoint::Run() } } - ZEN_INFO("InitializeServerLogging"); InitializeServerLogging(m_ServerOptions); ZEN_INFO("Command line: {}", m_ServerOptions.CommandLine); diff --git a/src/zenserver/xmake.lua b/src/zenserver/xmake.lua index 7ea9d52cc..470fbd24e 100644 --- a/src/zenserver/xmake.lua +++ b/src/zenserver/xmake.lua @@ -41,14 +41,6 @@ target("zenserver") add_ldflags("-framework SystemConfiguration") end - if is_plat("linux") then - add_includedirs("$(projectdir)/thirdparty/systemd/include") - add_linkdirs("$(projectdir)/thirdparty/systemd/lib") - add_links("systemd") - add_links("cap") - end - - add_options("compute") add_options("exec") diff --git a/src/zenutil/include/zenutil/service.h b/src/zenutil/include/zenutil/service.h index 2798bcb1f..a8bb868b3 100644 --- a/src/zenutil/include/zenutil/service.h +++ b/src/zenutil/include/zenutil/service.h @@ -53,4 +53,6 @@ std::error_code QueryInstalledService(std::string_view ServiceName, ServiceInfo& std::error_code StartService(std::string_view ServiceName); std::error_code StopService(std::string_view ServiceName); +void ReportServiceStatus(ServiceStatus Status); + } // namespace zen diff --git a/src/zenutil/service.cpp b/src/zenutil/service.cpp index ab9553cf4..bf2d7d630 100644 --- a/src/zenutil/service.cpp +++ b/src/zenutil/service.cpp @@ -25,11 +25,54 @@ # include <unistd.h> # include <sys/stat.h> # include <regex> + +ZEN_THIRD_PARTY_INCLUDES_START +# include <systemd/sd-daemon.h> +ZEN_THIRD_PARTY_INCLUDES_END + #endif namespace zen { using namespace std::literals; +void +ReportServiceStatus(ServiceStatus Status) +{ +#if ZEN_PLATFORM_WINDOWS + switch (Status) + { + case ServiceStatus::Starting: + ReportSvcStatus(SERVICE_START_PENDING, NO_ERROR, 3000); + break; + case ServiceStatus::Running: + ReportSvcStatus(SERVICE_RUNNING, NO_ERROR, 0); + break; + case ServiceStatus::Stopping: + ReportSvcStatus(SERVICE_STOP_PENDING, NO_ERROR, 0); + break; + case ServiceStatus::Stopped: + ReportSvcStatus(SERVICE_STOPPED, (DWORD)ApplicationExitCode(), 0); + break; + default: + break; + } +#elif ZEN_PLATFORM_LINUX + switch (Status) + { + case ServiceStatus::Running: + sd_notify(0, "READY=1"); + break; + case ServiceStatus::Stopping: + sd_notify(0, "STOPPING=1"); + break; + case ServiceStatus::Stopped: + sd_notifyf(0, "EXIT_STATUS=%d", ApplicationExitCode()); + break; + } +#endif + (void)Status; +} + namespace { #if ZEN_PLATFORM_WINDOWS diff --git a/src/zenutil/xmake.lua b/src/zenutil/xmake.lua index 3d95651f2..6d87aefcc 100644 --- a/src/zenutil/xmake.lua +++ b/src/zenutil/xmake.lua @@ -8,3 +8,11 @@ target('zenutil') add_includedirs("include", {public=true}) add_deps("zencore", "zenhttp") add_packages("vcpkg::robin-map", "vcpkg::spdlog") + + if is_plat("linux") then + add_includedirs("$(projectdir)/thirdparty/systemd/include") + add_linkdirs("$(projectdir)/thirdparty/systemd/lib") + add_links("systemd") + add_links("cap") + end + |