Skip to content

Commit

Permalink
Address comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
CPWstatic committed Sep 27, 2021
1 parent bd91d93 commit 8fc309f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 36 deletions.
2 changes: 1 addition & 1 deletion cmake/nebula/ThirdPartyConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
15 changes: 4 additions & 11 deletions src/daemons/GraphDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
* attached with Common Clause Condition 1.0, found in the LICENSES directory.
*/

#if defined(__x86_64__)
#include <breakpad/client/linux/handler/exception_handler.h>
#endif
#include <errno.h>
#include <folly/ssl/Init.h>
#include <signal.h>
Expand Down Expand Up @@ -34,17 +31,14 @@ using nebula::graph::GraphService;
using nebula::network::NetworkUtils;

static std::unique_ptr<apache::thrift::ThriftServer> gServer;
#if defined(__x86_64__)
static std::unique_ptr<google_breakpad::ExceptionHandler> gExceptionHandler;
#endif

static void signalHandler(int sig);
static Status setupSignalHandler();
extern Status setupLogging();
static void printHelp(const char *prog);
static void setupThreadManager();
#if defined(__x86_64__)
extern StatusOr<std::unique_ptr<google_breakpad::ExceptionHandler>> setupBreakpad();
extern Status setupBreakpad();
#endif

DECLARE_string(flagfile);
Expand Down Expand Up @@ -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
Expand Down
15 changes: 4 additions & 11 deletions src/daemons/MetaDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
* attached with Common Clause Condition 1.0, found in the LICENSES directory.
*/

#if defined(__x86_64__)
#include <breakpad/client/linux/handler/exception_handler.h>
#endif
#include <folly/ssl/Init.h>
#include <thrift/lib/cpp2/server/ThriftServer.h>

Expand Down Expand Up @@ -60,15 +57,12 @@ DEFINE_bool(daemonize, true, "Whether run as a daemon process");

static std::unique_ptr<apache::thrift::ThriftServer> gServer;
static std::unique_ptr<nebula::kvstore::KVStore> gKVStore;
#if defined(__x86_64__)
static std::unique_ptr<google_breakpad::ExceptionHandler> gExceptionHandler;
#endif

static void signalHandler(int sig);
static Status setupSignalHandler();
extern Status setupLogging();
#if defined(__x86_64__)
extern StatusOr<std::unique_ptr<google_breakpad::ExceptionHandler>> setupBreakpad();
extern Status setupBreakpad();
#endif

namespace nebula {
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions src/daemons/SetupBreakpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@
#include "common/base/StatusOr.h"
#include "common/fs/FileUtils.h"

static std::unique_ptr<google_breakpad::ExceptionHandler> gExceptionHandler;

DECLARE_string(log_dir);

using nebula::Status;
using nebula::StatusOr;
using nebula::fs::FileUtils;

StatusOr<std::unique_ptr<google_breakpad::ExceptionHandler>> 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<google_breakpad::ExceptionHandler>(
gExceptionHandler = std::make_unique<google_breakpad::ExceptionHandler>(
descriptor, nullptr, nullptr, nullptr, true, -1);
return Status::OK();
}
#endif
15 changes: 4 additions & 11 deletions src/daemons/StorageDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
* attached with Common Clause Condition 1.0, found in the LICENSES directory.
*/

#if defined(__x86_64__)
#include <breakpad/client/linux/handler/exception_handler.h>
#endif
#include <folly/ssl/Init.h>
#include <thrift/lib/cpp2/server/ThriftServer.h>

Expand Down Expand Up @@ -50,13 +47,10 @@ static void signalHandler(int sig);
static Status setupSignalHandler();
extern Status setupLogging();
#if defined(__x86_64__)
extern StatusOr<std::unique_ptr<google_breakpad::ExceptionHandler>> setupBreakpad();
extern Status setupBreakpad();
#endif

std::unique_ptr<nebula::storage::StorageServer> gStorageServer;
#if defined(__x86_64__)
static std::unique_ptr<google_breakpad::ExceptionHandler> gExceptionHandler;
#endif

int main(int argc, char *argv[]) {
google::SetVersionString(nebula::versionString());
Expand All @@ -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;
Expand Down

0 comments on commit 8fc309f

Please sign in to comment.