Fix API server kicking in early before init readiness.

This commit is contained in:
kishorenc 2020-03-25 08:48:01 +05:30
parent 7cc8acfe45
commit 901795869d
3 changed files with 5 additions and 5 deletions

View File

@ -34,7 +34,7 @@ private:
std::string version;
std::vector<route_path> routes;
std::vector<route_path> routes; // TODO: must be a hashmap?
const std::string listen_address;

View File

@ -217,9 +217,9 @@ int HttpServer::find_route(const std::vector<std::string> & path_parts, const st
bool found = true;
for(size_t i = 0; i < rpath.path_parts.size(); i++) {
const std::string & rpart = rpath.path_parts[i];
const std::string & given_part = path_parts[i];
for(size_t j = 0; j < rpath.path_parts.size(); j++) {
const std::string & rpart = rpath.path_parts[j];
const std::string & given_part = path_parts[j];
if(rpart != given_part && rpart[0] != ':') {
found = false;
break;

View File

@ -317,7 +317,7 @@ int run_server(const Config & config, const std::string & version,
// Wait for raft service to be ready before starting http
// Follower or leader must have started AND data must also have been loaded
LOG(INFO) << "Waiting for peering service to be ready before starting API service...";
while(replication_state.get_init_readiness_count() >= 2) {
while(replication_state.get_init_readiness_count() < 2) {
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}