From 59c457cd5b1f5e82288fa340ee3b6a5879352fd1 Mon Sep 17 00:00:00 2001 From: groot Date: Thu, 27 Jun 2019 19:57:11 +0800 Subject: [PATCH] add more error handling Former-commit-id: 0105341107a2d54e23921b71168001cb5b218447 --- cpp/src/server/DBWrapper.cpp | 10 +++++++--- cpp/src/server/MilvusServer.cpp | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cpp/src/server/DBWrapper.cpp b/cpp/src/server/DBWrapper.cpp index 2a583a66..7892a57f 100644 --- a/cpp/src/server/DBWrapper.cpp +++ b/cpp/src/server/DBWrapper.cpp @@ -37,12 +37,16 @@ DBWrapper::DBWrapper() { opt.meta.archive_conf.SetCriterias(criterial); //create db root folder - CommonUtil::CreateDirectory(opt.meta.path); + ServerError err = CommonUtil::CreateDirectory(opt.meta.path); + if(err != SERVER_SUCCESS) { + std::cout << "ERROR! Failed to create database root path: " << opt.meta.path << std::endl; + kill(0, SIGUSR1); + } zilliz::milvus::engine::DB::Open(opt, &db_); if(db_ == nullptr) { - SERVER_LOG_ERROR << "Failed to open db"; - throw ServerException(SERVER_NULL_POINTER, "Failed to open db"); + std::cout << "ERROR! Failed to open database" << std::endl; + kill(0, SIGUSR1); } } diff --git a/cpp/src/server/MilvusServer.cpp b/cpp/src/server/MilvusServer.cpp index 5e42eb3d..32246096 100644 --- a/cpp/src/server/MilvusServer.cpp +++ b/cpp/src/server/MilvusServer.cpp @@ -23,6 +23,7 @@ #include #include +#include namespace zilliz { namespace milvus { @@ -92,7 +93,8 @@ MilvusServer::StartService() { return; } } catch (apache::thrift::TException& ex) { - //SERVER_LOG_ERROR << "Server encounter exception: " << ex.what(); + std::cout << "ERROR! " << ex.what() << std::endl; + kill(0, SIGUSR1); } } -- GitLab