diff options
| author | Liam Mitchell <[email protected]> | 2026-03-09 18:25:30 -0700 |
|---|---|---|
| committer | Liam Mitchell <[email protected]> | 2026-03-09 18:25:30 -0700 |
| commit | 57c1683b2935c834250b73eb506319ed67946160 (patch) | |
| tree | 1fc8f237010b26e65659b731fe6f6eae30422f5c /src/zenserver/main.cpp | |
| parent | Allow external OidcToken executable to be specified unless disabled via comma... (diff) | |
| parent | reduce lock time for project store gc precache and gc validate (#750) (diff) | |
| download | zen-57c1683b2935c834250b73eb506319ed67946160.tar.xz zen-57c1683b2935c834250b73eb506319ed67946160.zip | |
Merge branch 'main' into lm/oidctoken-exe-path
Diffstat (limited to 'src/zenserver/main.cpp')
| -rw-r--r-- | src/zenserver/main.cpp | 73 |
1 files changed, 58 insertions, 15 deletions
diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp index 34848c831..3a58d1f4a 100644 --- a/src/zenserver/main.cpp +++ b/src/zenserver/main.cpp @@ -19,12 +19,15 @@ #include <zencore/thread.h> #include <zencore/trace.h> #include <zentelemetry/otlptrace.h> +#include <zenutil/commandlineoptions.h> #include <zenutil/service.h> #include "diag/logging.h" #include "storage/storageconfig.h" #include "storage/zenstorageserver.h" +#include "hub/zenhubserver.h" + #if ZEN_PLATFORM_WINDOWS # include <zencore/windows.h> # include <zenutil/windows/windowsservice.h> @@ -54,8 +57,6 @@ SignalCallbackHandler(int SigNum) namespace zen { -using namespace std::literals; - ////////////////////////////////////////////////////////////////////////// #if ZEN_PLATFORM_WINDOWS @@ -89,6 +90,13 @@ AppMain(int argc, char* argv[]) { using namespace std::literals; + signal(SIGINT, utils::SignalCallbackHandler); + signal(SIGTERM, utils::SignalCallbackHandler); + +#if ZEN_PLATFORM_LINUX + IgnoreChildSignals(); +#endif + try { typename Main::Config ServerOptions; @@ -188,12 +196,12 @@ AppMain(int argc, char* argv[]) } catch (const AssertException& AssertEx) { - fprintf(stderr, ZEN_APP_NAME " ERROR: Caught assert exception in main: '%s'", AssertEx.FullDescription().c_str()); + fprintf(stderr, ZEN_APP_NAME " ERROR: Caught assert exception in main: '%s'\n", AssertEx.FullDescription().c_str()); return 1; } catch (const std::exception& Ex) { - fprintf(stderr, ZEN_APP_NAME " ERROR: Caught exception in main: '%s'", Ex.what()); + fprintf(stderr, ZEN_APP_NAME " ERROR: Caught exception in main: '%s'\n", Ex.what()); return 1; } @@ -206,6 +214,10 @@ AppMain(int argc, char* argv[]) int test_main(int argc, char** argv) { +# if ZEN_PLATFORM_WINDOWS + setlocale(LC_ALL, "en_us.UTF8"); +# endif // ZEN_PLATFORM_WINDOWS + zen::logging::InitializeLogging(); zen::logging::SetLogLevel(zen::logging::level::Debug); @@ -218,27 +230,58 @@ test_main(int argc, char** argv) int main(int argc, char* argv[]) { +#if ZEN_PLATFORM_WINDOWS + setlocale(LC_ALL, "en_us.UTF8"); +#endif // ZEN_PLATFORM_WINDOWS + + zen::CommandLineConverter ArgConverter(argc, argv); + using namespace zen; + using namespace std::literals; + + auto _ = zen::MakeGuard([] { + // Allow some time for worker threads to unravel, in an effort + // to prevent shutdown races in TLS object destruction + WaitForThreads(1000); + }); + + enum + { + kHub, + kStore, + kTest + } ServerMode = kStore; if (argc >= 2) { - if (argv[1] == "test"sv) + if (argv[1] == "hub"sv) { + ServerMode = kHub; + } + else if (argv[1] == "store"sv) + { + ServerMode = kStore; + } + else if (argv[1] == "test"sv) + { + ServerMode = kTest; + } + } + + switch (ServerMode) + { + case kTest: #if ZEN_WITH_TESTS return test_main(argc, argv); #else fprintf(stderr, "test option not available in release mode!\n"); exit(5); #endif - } + break; + case kHub: + return AppMain<ZenHubServerMain>(argc, argv); + default: + case kStore: + return AppMain<ZenStorageServerMain>(argc, argv); } - - signal(SIGINT, utils::SignalCallbackHandler); - signal(SIGTERM, utils::SignalCallbackHandler); - -#if ZEN_PLATFORM_LINUX - IgnoreChildSignals(); -#endif - - return AppMain<ZenStorageServerMain>(argc, argv); } |