Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix meta can't be stopped #2240

Merged
merged 2 commits into from
Jul 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/daemons/MetaDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ DEFINE_bool(daemonize, true, "Whether run as a daemon process");
DECLARE_bool(check_leader);

static std::unique_ptr<apache::thrift::ThriftServer> gServer;
static std::unique_ptr<nebula::kvstore::KVStore> gKVStore;
static void signalHandler(int sig);
static Status setupSignalHandler();

Expand Down Expand Up @@ -210,8 +211,8 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}

auto kvstore = initKV(peersRet.value(), localhost);
if (kvstore == nullptr) {
gKVStore = initKV(peersRet.value(), localhost);
if (gKVStore == nullptr) {
LOG(ERROR) << "Init kv failed!";
return EXIT_FAILURE;
}
Expand All @@ -222,15 +223,15 @@ int main(int argc, char *argv[]) {
pool->start(FLAGS_meta_http_thread_num, "http thread pool");

auto webSvc = std::make_unique<nebula::WebService>();
status = initWebService(webSvc.get(), kvstore.get(), helper.get(), pool.get());
status = initWebService(webSvc.get(), gKVStore.get(), helper.get(), pool.get());
if (!status.ok()) {
LOG(ERROR) << "Init web service failed: " << status;
return EXIT_FAILURE;
}

{
nebula::meta::JobManager* jobMgr = nebula::meta::JobManager::getInstance();
if (!jobMgr->init(kvstore.get())) {
if (!jobMgr->init(gKVStore.get())) {
LOG(ERROR) << "Init job manager failed";
return EXIT_FAILURE;
}
Expand All @@ -240,16 +241,16 @@ int main(int argc, char *argv[]) {
/**
* Only leader part needed.
*/
auto ret = kvstore->partLeader(nebula::meta::kDefaultSpaceId,
nebula::meta::kDefaultPartId);
auto ret = gKVStore->partLeader(nebula::meta::kDefaultSpaceId,
nebula::meta::kDefaultPartId);
if (!nebula::ok(ret)) {
LOG(ERROR) << "Part leader get failed";
return EXIT_FAILURE;
}
if (nebula::value(ret) == localhost) {
LOG(INFO) << "Check and init root user";
if (!nebula::meta::RootUserMan::isUserExists(kvstore.get())) {
if(!nebula::meta::RootUserMan::initRootUser(kvstore.get())) {
if (!nebula::meta::RootUserMan::isUserExists(gKVStore.get())) {
if (!nebula::meta::RootUserMan::initRootUser(gKVStore.get())) {
LOG(ERROR) << "Init root user failed";
return EXIT_FAILURE;
}
Expand All @@ -264,7 +265,7 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}

auto handler = std::make_shared<nebula::meta::MetaServiceHandler>(kvstore.get(), gClusterId);
auto handler = std::make_shared<nebula::meta::MetaServiceHandler>(gKVStore.get(), gClusterId);
LOG(INFO) << "The meta deamon start on " << localhost;
try {
gServer = std::make_unique<apache::thrift::ThriftServer>();
Expand Down Expand Up @@ -304,6 +305,10 @@ void signalHandler(int sig) {
auto gJobMgr = nebula::meta::JobManager::getInstance();
gJobMgr->shutDown();
}
if (gKVStore) {
gKVStore->stop();
gKVStore.reset();
}
break;
default:
FLOG_ERROR("Signal %d(%s) received but ignored", sig, ::strsignal(sig));
Expand Down