From 03dddb20a2a378eaf8c529a986ccfaeb8ee019a7 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Fri, 17 Sep 2021 19:11:11 +0200 Subject: Implemented basics for Windows server support (not yet 100% - needs to properly report service state etc to the OS) --- zenserver/zenserver.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'zenserver/zenserver.cpp') diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index eb0324161..f36cfba48 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -11,9 +11,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -40,6 +40,10 @@ #include "config.h" #include "diag/logging.h" +#if ZEN_PLATFORM_WINDOWS +# include "windows/service.h" +#endif + ////////////////////////////////////////////////////////////////////////// // Sentry // @@ -422,7 +426,7 @@ private: bool m_DebugOptionForcedCrash = false; }; -} +} // namespace zen int main(int argc, char* argv[]) @@ -436,6 +440,22 @@ main(int argc, char* argv[]) ParseGlobalCliOptions(argc, argv, GlobalOptions, ServiceConfig); InitializeLogging(GlobalOptions); +#if ZEN_PLATFORM_WINDOWS + if (GlobalOptions.InstallService) + { + SvcInstall(); + + std::exit(0); + } + + if (GlobalOptions.UninstallService) + { + SvcDelete(); + + std::exit(0); + } +#endif + #if USE_SENTRY // Initialize sentry.io client @@ -443,7 +463,7 @@ main(int argc, char* argv[]) sentry_options_set_dsn(SentryOptions, "https://8ba3441bebc941c1ae24b8cd2fd25d55@o10593.ingest.sentry.io/5919284"); sentry_init(SentryOptions); - auto _ = zen::MakeGuard([&] { sentry_close(); }); + auto _ = zen::MakeGuard([] { sentry_close(); }); #endif try -- cgit v1.2.3