aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenserver/main.cpp')
-rw-r--r--src/zenserver/main.cpp48
1 files changed, 21 insertions, 27 deletions
diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp
index 571dd3b4f..00b7a67d7 100644
--- a/src/zenserver/main.cpp
+++ b/src/zenserver/main.cpp
@@ -3,6 +3,7 @@
#include <zencore/compactbinarybuilder.h>
#include <zencore/compactbinaryvalidation.h>
#include <zencore/config.h>
+#include <zencore/crashhandler.h>
#include <zencore/except.h>
#include <zencore/filesystem.h>
#include <zencore/fmtutils.h>
@@ -31,6 +32,8 @@
#include "hub/zenhubserver.h"
+#include "proxy/zenproxyserver.h"
+
#if ZEN_PLATFORM_WINDOWS
# include <zencore/windows.h>
# include <zenutil/windows/windowsservice.h>
@@ -41,7 +44,6 @@
// in some shared code into the executable
#if ZEN_WITH_TESTS
-# define ZEN_TEST_WITH_RUNNER 1
# include <zencore/testing.h>
#endif
@@ -121,10 +123,6 @@ AppMain(int argc, char* argv[])
signal(SIGINT, utils::SignalCallbackHandler);
signal(SIGTERM, utils::SignalCallbackHandler);
-#if ZEN_PLATFORM_LINUX
- IgnoreChildSignals();
-#endif
-
try
{
typename Main::Config ServerOptions;
@@ -247,17 +245,21 @@ test_main(int argc, char** argv)
# endif // ZEN_PLATFORM_WINDOWS
zen::logging::InitializeLogging();
- zen::logging::SetLogLevel(zen::logging::level::Debug);
+ zen::logging::SetLogLevel(zen::logging::Debug);
zen::MaximizeOpenFileCount();
- return ZEN_RUN_TESTS(argc, argv);
+ zen::testing::TestRunner Runner;
+ Runner.ApplyCommandLine(argc, argv);
+ return Runner.Run();
}
#endif
int
main(int argc, char* argv[])
{
+ zen::InstallCrashHandler();
+
#if ZEN_PLATFORM_WINDOWS
setlocale(LC_ALL, "en_us.UTF8");
#endif // ZEN_PLATFORM_WINDOWS
@@ -267,31 +269,12 @@ main(int argc, char* argv[])
using namespace zen;
using namespace std::literals;
- // note: doctest has locally (in thirdparty) been fixed to not cause shutdown
- // crashes due to TLS destructors
- //
- // mimalloc on the other hand might still be causing issues, in which case
- // we should work out either how to eliminate the mimalloc dependency or how
- // to configure it in a way that doesn't cause shutdown issues
-
-#if 0
- auto _ = zen::MakeGuard([] {
- // Allow some time for worker threads to unravel, in an effort
- // to prevent shutdown races in TLS object destruction, mainly due to
- // threads which we don't directly control (Windows thread pool) and
- // therefore can't join.
- //
- // This isn't a great solution, but for now it seems to help reduce
- // shutdown crashes observed in some situations.
- WaitForThreads(1000);
- });
-#endif
-
enum
{
kHub,
kStore,
kCompute,
+ kProxy,
kTest
} ServerMode = kStore;
@@ -309,10 +292,19 @@ main(int argc, char* argv[])
{
ServerMode = kCompute;
}
+ else if (argv[1] == "proxy"sv)
+ {
+ ServerMode = kProxy;
+ }
else if (argv[1] == "test"sv)
{
ServerMode = kTest;
}
+ else if (argv[1][0] != '-')
+ {
+ fprintf(stderr, "unknown mode '%s'. Available modes: hub, store, compute, proxy, test\n", argv[1]);
+ return 1;
+ }
}
switch (ServerMode)
@@ -334,6 +326,8 @@ main(int argc, char* argv[])
fprintf(stderr, "compute services are not compiled in!\n");
exit(5);
#endif
+ case kProxy:
+ return AppMain<ZenProxyServerMain>(argc, argv);
default:
case kStore:
return AppMain<ZenStorageServerMain>(argc, argv);