diff --git a/cmake/nebula/ThirdPartyConfig.cmake b/cmake/nebula/ThirdPartyConfig.cmake index 16aa4e895b7..838876fff33 100644 --- a/cmake/nebula/ThirdPartyConfig.cmake +++ b/cmake/nebula/ThirdPartyConfig.cmake @@ -107,7 +107,7 @@ find_package(LibLZMA REQUIRED) find_package(Fizz REQUIRED) find_package(Sodium REQUIRED) if (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "x86_64") -find_package(Breakpad REQUIRED) + find_package(Breakpad REQUIRED) endif() set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L ${NEBULA_THIRDPARTY_ROOT}/lib") diff --git a/src/daemons/GraphDaemon.cpp b/src/daemons/GraphDaemon.cpp index 10106009531..43430942f2b 100644 --- a/src/daemons/GraphDaemon.cpp +++ b/src/daemons/GraphDaemon.cpp @@ -4,9 +4,6 @@ * attached with Common Clause Condition 1.0, found in the LICENSES directory. */ -#if defined(__x86_64__) -#include -#endif #include #include #include @@ -34,9 +31,6 @@ using nebula::graph::GraphService; using nebula::network::NetworkUtils; static std::unique_ptr gServer; -#if defined(__x86_64__) -static std::unique_ptr gExceptionHandler; -#endif static void signalHandler(int sig); static Status setupSignalHandler(); @@ -44,7 +38,7 @@ extern Status setupLogging(); static void printHelp(const char *prog); static void setupThreadManager(); #if defined(__x86_64__) -extern StatusOr> setupBreakpad(); +extern Status setupBreakpad(); #endif DECLARE_string(flagfile); @@ -81,12 +75,11 @@ int main(int argc, char *argv[]) { } #if defined(__x86_64__) - auto expHandler = setupBreakpad(); - if (!expHandler.ok()) { - LOG(ERROR) << expHandler.status(); + status = setupBreakpad(); + if (!status.ok()) { + LOG(ERROR) << status; return EXIT_FAILURE; } - gExceptionHandler = std::move(expHandler).value(); #endif // Detect if the server has already been started diff --git a/src/daemons/MetaDaemon.cpp b/src/daemons/MetaDaemon.cpp index be9df4f5173..83bdb2e9643 100644 --- a/src/daemons/MetaDaemon.cpp +++ b/src/daemons/MetaDaemon.cpp @@ -4,9 +4,6 @@ * attached with Common Clause Condition 1.0, found in the LICENSES directory. */ -#if defined(__x86_64__) -#include -#endif #include #include @@ -60,15 +57,12 @@ DEFINE_bool(daemonize, true, "Whether run as a daemon process"); static std::unique_ptr gServer; static std::unique_ptr gKVStore; -#if defined(__x86_64__) -static std::unique_ptr gExceptionHandler; -#endif static void signalHandler(int sig); static Status setupSignalHandler(); extern Status setupLogging(); #if defined(__x86_64__) -extern StatusOr> setupBreakpad(); +extern Status setupBreakpad(); #endif namespace nebula { @@ -210,12 +204,11 @@ int main(int argc, char* argv[]) { } #if defined(__x86_64__) - auto expHandler = setupBreakpad(); - if (!expHandler.ok()) { - LOG(ERROR) << expHandler.status(); + status = setupBreakpad(); + if (!status.ok()) { + LOG(ERROR) << status; return EXIT_FAILURE; } - gExceptionHandler = std::move(expHandler).value(); #endif auto pidPath = FLAGS_pid_file; diff --git a/src/daemons/SetupBreakpad.cpp b/src/daemons/SetupBreakpad.cpp index a0eee233e6e..1e7f9fd53bd 100644 --- a/src/daemons/SetupBreakpad.cpp +++ b/src/daemons/SetupBreakpad.cpp @@ -11,18 +11,21 @@ #include "common/base/StatusOr.h" #include "common/fs/FileUtils.h" +static std::unique_ptr gExceptionHandler; + DECLARE_string(log_dir); using nebula::Status; using nebula::StatusOr; using nebula::fs::FileUtils; -StatusOr> setupBreakpad() { +Status setupBreakpad() { if (!FileUtils::exist(FLAGS_log_dir)) { return Status::Error("Log directory does not exist:`%s'", FLAGS_log_dir.c_str()); } google_breakpad::MinidumpDescriptor descriptor(FLAGS_log_dir); - return std::make_unique( + gExceptionHandler = std::make_unique( descriptor, nullptr, nullptr, nullptr, true, -1); + return Status::OK(); } #endif diff --git a/src/daemons/StorageDaemon.cpp b/src/daemons/StorageDaemon.cpp index b0f6d9d65fa..58603620e1a 100644 --- a/src/daemons/StorageDaemon.cpp +++ b/src/daemons/StorageDaemon.cpp @@ -4,9 +4,6 @@ * attached with Common Clause Condition 1.0, found in the LICENSES directory. */ -#if defined(__x86_64__) -#include -#endif #include #include @@ -50,13 +47,10 @@ static void signalHandler(int sig); static Status setupSignalHandler(); extern Status setupLogging(); #if defined(__x86_64__) -extern StatusOr> setupBreakpad(); +extern Status setupBreakpad(); #endif std::unique_ptr gStorageServer; -#if defined(__x86_64__) -static std::unique_ptr gExceptionHandler; -#endif int main(int argc, char *argv[]) { google::SetVersionString(nebula::versionString()); @@ -73,12 +67,11 @@ int main(int argc, char *argv[]) { } #if defined(__x86_64__) - auto expHandler = setupBreakpad(); - if (!expHandler.ok()) { - LOG(ERROR) << expHandler.status(); + status = setupBreakpad(); + if (!status.ok()) { + LOG(ERROR) << status; return EXIT_FAILURE; } - gExceptionHandler = std::move(expHandler).value(); #endif auto pidPath = FLAGS_pid_file;