Skip to content

Commit

Permalink
Fixed graphd startup issue (#5493)
Browse files Browse the repository at this point in the history
  • Loading branch information
dutor authored Apr 13, 2023
1 parent 8a797fa commit 0adad87
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/graph/service/GraphServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,23 @@ bool GraphServer::start() {
} catch (const std::exception &e) {
FLOG_ERROR("Exception thrown while starting the graph RPC server: %s", e.what());
}
serverStatus_.store(STATUS_STOPPED);
{
std::unique_lock<std::mutex> lkStop(muStop_);
serverStatus_.store(STATUS_STOPPED);
cvStop_.notify_one();
}
FLOG_INFO("nebula-graphd on %s:%d has been stopped", localHost_.host.c_str(), localHost_.port);
});

while (serverStatus_ == STATUS_UNINITIALIZED) {
std::this_thread::sleep_for(std::chrono::microseconds(100));
std::this_thread::sleep_for(std::chrono::microseconds(1000));
}
// In case `thriftServer_->serve()` fails, we wait a short while
std::this_thread::sleep_for(std::chrono::microseconds(1000));
if (serverStatus_ != STATUS_RUNNING) {
return false;
}

return true;
}

Expand All @@ -89,10 +99,8 @@ void GraphServer::waitUntilStop() {

void GraphServer::notifyStop() {
std::unique_lock<std::mutex> lkStop(muStop_);
if (serverStatus_ == STATUS_RUNNING) {
serverStatus_ = STATUS_STOPPED;
cvStop_.notify_one();
}
serverStatus_ = STATUS_STOPPED;
cvStop_.notify_one();
}

// Stop the server.
Expand Down

0 comments on commit 0adad87

Please sign in to comment.