aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/service.cpp
diff options
context:
space:
mode:
authorLiam Mitchell <[email protected]>2025-08-22 22:29:14 +0000
committerLiam Mitchell <[email protected]>2025-08-22 22:29:14 +0000
commitb905b6d1d94c2a09c268603935991ee3c018c700 (patch)
treeebc8885ebb627b52edbf4ab36427a571916e8d9d /src/zenutil/service.cpp
parentRemove workflow hacks for CI debugging (diff)
downloadzen-b905b6d1d94c2a09c268603935991ee3c018c700.tar.xz
zen-b905b6d1d94c2a09c268603935991ee3c018c700.zip
Move ReportServiceStatus to zenutil and remove extraneous logging
Diffstat (limited to 'src/zenutil/service.cpp')
-rw-r--r--src/zenutil/service.cpp43
1 files changed, 43 insertions, 0 deletions
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