diff options
| author | Stefan Boberg <[email protected]> | 2021-09-17 19:11:11 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-17 19:11:11 +0200 |
| commit | 03dddb20a2a378eaf8c529a986ccfaeb8ee019a7 (patch) | |
| tree | 2aa5ee04c38ae5a69acf2558e736e9eb785c2284 /zenserver/zenserver.cpp | |
| parent | Added UNICODE and defined _WIN32_WINNT to match the sln (diff) | |
| download | zen-03dddb20a2a378eaf8c529a986ccfaeb8ee019a7.tar.xz zen-03dddb20a2a378eaf8c529a986ccfaeb8ee019a7.zip | |
Implemented basics for Windows server support (not yet 100% - needs to properly report service state etc to the OS)
Diffstat (limited to 'zenserver/zenserver.cpp')
| -rw-r--r-- | zenserver/zenserver.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
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 <zencore/timer.h> #include <zencore/windows.h> #include <zenhttp/httpserver.h> -#include <zenutil/zenserverprocess.h> #include <zenstore/cas.h> #include <zenstore/cidstore.h> +#include <zenutil/zenserverprocess.h> #include <fmt/format.h> #include <mimalloc-new-delete.h> @@ -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://[email protected]/5919284"); sentry_init(SentryOptions); - auto _ = zen::MakeGuard([&] { sentry_close(); }); + auto _ = zen::MakeGuard([] { sentry_close(); }); #endif try |