aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2022-01-11 10:30:06 +0100
committerPer Larsson <[email protected]>2022-01-11 10:30:06 +0100
commitdf6cc027049089501a6ca9427400277492b8e5a4 (patch)
tree9f7e71215074faf2b32e8f83da8c3a8af45fd5d6
parentFixed error in if-statement comparison (diff)
downloadzen-df6cc027049089501a6ca9427400277492b8e5a4.tar.xz
zen-df6cc027049089501a6ca9427400277492b8e5a4.zip
Added option to disable Sentry crash handler.
-rw-r--r--zenserver/config.cpp3
-rw-r--r--zenserver/config.h1
-rw-r--r--zenserver/zenserver.cpp23
3 files changed, 19 insertions, 8 deletions
diff --git a/zenserver/config.cpp b/zenserver/config.cpp
index 722bc3b97..f7b2f15fa 100644
--- a/zenserver/config.cpp
+++ b/zenserver/config.cpp
@@ -139,6 +139,9 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions)
options.add_options()("content-dir", "Frontend content directory", cxxopts::value<std::filesystem::path>(ServerOptions.ContentDir));
options.add_options()("abslog", "Path to log file", cxxopts::value<std::filesystem::path>(ServerOptions.AbsLogFile));
options.add_options()("config", "Path to Lua config file", cxxopts::value<std::filesystem::path>(ServerOptions.ConfigFile));
+ options.add_options()("no-sentry",
+ "Disable Sentry crash handler",
+ cxxopts::value<bool>(ServerOptions.NoSentry)->default_value("false"));
options
.add_option("lifetime", "", "owner-pid", "Specify owning process id", cxxopts::value<int>(ServerOptions.OwnerPid), "<identifier>");
diff --git a/zenserver/config.h b/zenserver/config.h
index 023e297c9..e994c248e 100644
--- a/zenserver/config.h
+++ b/zenserver/config.h
@@ -103,6 +103,7 @@ struct ZenServerOptions
bool StructuredCacheEnabled = true;
bool ShouldCrash = false; // Option for testing crash handling
bool IsFirstRun = false;
+ bool NoSentry = false;
#if ZEN_WITH_TRACE
std::string TraceHost; // Host name or IP address to send trace data to
std::string TraceFile; // Path of a file to write a trace
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp
index 6e5d2fe93..77f7a3d64 100644
--- a/zenserver/zenserver.cpp
+++ b/zenserver/zenserver.cpp
@@ -154,6 +154,7 @@ public:
{
using namespace fmt::literals;
+ m_UseSentry = ServerOptions.NoSentry == false;
m_ServerEntry = ServerEntry;
m_DebugOptionForcedCrash = ServerOptions.ShouldCrash;
const int ParentPid = ServerOptions.OwnerPid;
@@ -343,7 +344,11 @@ public:
ZEN_INFO(ZEN_APP_NAME " now running (pid: {})", zen::GetCurrentProcessId());
#if USE_SENTRY
- sentry_clear_modulecache();
+ ZEN_INFO("sentry crash handler {}", m_UseSentry ? "ENABLED" : "DISABLED");
+ if (m_UseSentry)
+ {
+ sentry_clear_modulecache();
+ }
#endif
if (m_DebugOptionForcedCrash)
@@ -549,6 +554,7 @@ private:
#endif
bool m_DebugOptionForcedCrash = false;
+ bool m_UseSentry = false;
};
void
@@ -803,14 +809,15 @@ int
ZenEntryPoint::Run()
{
#if USE_SENTRY
- // Initialize sentry.io client
-
- sentry_options_t* SentryOptions = sentry_options_new();
- sentry_options_set_dsn(SentryOptions, "https://[email protected]/5919284");
- sentry_options_set_database_path(SentryOptions, PathToUtf8(m_ServerOptions.DataDir / ".sentry-native").c_str());
- sentry_init(SentryOptions);
+ if (m_ServerOptions.NoSentry == false)
+ {
+ sentry_options_t* SentryOptions = sentry_options_new();
+ sentry_options_set_dsn(SentryOptions, "https://[email protected]/5919284");
+ sentry_options_set_database_path(SentryOptions, PathToUtf8(m_ServerOptions.DataDir / ".sentry-native").c_str());
+ sentry_init(SentryOptions);
- auto _ = zen::MakeGuard([] { sentry_close(); });
+ auto _ = zen::MakeGuard([] { sentry_close(); });
+ }
#endif
auto& ServerOptions = m_ServerOptions;