mirror of https://github.com/milvus-io/milvus.git
MS-653 fix when config check fail, Milvus close without message
Former-commit-id: b9ff8c2228d07b6abe9d72f87e06bee823a05363pull/191/head
parent
c11820aff1
commit
30534bee23
|
@ -11,16 +11,17 @@ Please mark all change in change log and use the ticket from JIRA.
|
||||||
- MS-587 - Count get wrong result after adding vectors and index built immediately
|
- MS-587 - Count get wrong result after adding vectors and index built immediately
|
||||||
- MS-599 - Search wrong result when table created with metric_type: IP
|
- MS-599 - Search wrong result when table created with metric_type: IP
|
||||||
- MS-601 - Docker logs error caused by get CPUTemperature error
|
- MS-601 - Docker logs error caused by get CPUTemperature error
|
||||||
- MS-622 - Delete vectors should be failed if date range is invalid
|
|
||||||
- MS-620 - Get table row counts display wrong error code
|
- MS-620 - Get table row counts display wrong error code
|
||||||
|
- MS-622 - Delete vectors should be failed if date range is invalid
|
||||||
|
- MS-624 - Search vectors failed if time ranges long enough
|
||||||
- MS-637 - Out of memory when load too many tasks
|
- MS-637 - Out of memory when load too many tasks
|
||||||
|
- MS-639 - SQ8H index created failed and server hang
|
||||||
- MS-640 - Cache object size calculate incorrect
|
- MS-640 - Cache object size calculate incorrect
|
||||||
- MS-641 - Segment fault(signal 11) in PickToLoad
|
- MS-641 - Segment fault(signal 11) in PickToLoad
|
||||||
- MS-639 - SQ8H index created failed and server hang
|
|
||||||
- MS-647 - [monitor] grafana display average cpu-temp
|
|
||||||
- MS-644 - Search crashed with index-type: flat
|
- MS-644 - Search crashed with index-type: flat
|
||||||
- MS-624 - Search vectors failed if time ranges long enough
|
- MS-647 - [monitor] grafana display average cpu-temp
|
||||||
- MS-652 - IVFSQH quantization double free
|
- MS-652 - IVFSQH quantization double free
|
||||||
|
- MS-653 - When config check fail, Milvus close without message
|
||||||
|
|
||||||
## Improvement
|
## Improvement
|
||||||
- MS-552 - Add and change the easylogging library
|
- MS-552 - Add and change the easylogging library
|
||||||
|
@ -38,8 +39,8 @@ Please mark all change in change log and use the ticket from JIRA.
|
||||||
- MS-608 - Update TODO names
|
- MS-608 - Update TODO names
|
||||||
- MS-609 - Update task construct function
|
- MS-609 - Update task construct function
|
||||||
- MS-611 - Add resources validity check in ResourceMgr
|
- MS-611 - Add resources validity check in ResourceMgr
|
||||||
- MS-619 - Add optimizer class in scheduler
|
|
||||||
- MS-614 - Preload table at startup
|
- MS-614 - Preload table at startup
|
||||||
|
- MS-619 - Add optimizer class in scheduler
|
||||||
- MS-626 - Refactor DataObj to support cache any type data
|
- MS-626 - Refactor DataObj to support cache any type data
|
||||||
- MS-648 - Improve unittest
|
- MS-648 - Improve unittest
|
||||||
|
|
||||||
|
@ -59,8 +60,8 @@ Please mark all change in change log and use the ticket from JIRA.
|
||||||
- MS-600 - Reconstruct unittest code
|
- MS-600 - Reconstruct unittest code
|
||||||
- MS-602 - Remove zilliz namespace
|
- MS-602 - Remove zilliz namespace
|
||||||
- MS-610 - Change error code base value from hex to decimal
|
- MS-610 - Change error code base value from hex to decimal
|
||||||
- MS-635 - Add compile option to support customized faiss
|
|
||||||
- MS-624 - Re-organize project directory for open-source
|
- MS-624 - Re-organize project directory for open-source
|
||||||
|
- MS-635 - Add compile option to support customized faiss
|
||||||
|
|
||||||
# Milvus 0.4.0 (2019-09-12)
|
# Milvus 0.4.0 (2019-09-12)
|
||||||
|
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
|
|
||||||
#include "config/ConfigMgr.h"
|
|
||||||
#include "YamlConfigMgr.h"
|
|
||||||
|
|
||||||
namespace milvus {
|
|
||||||
namespace server {
|
|
||||||
|
|
||||||
ConfigMgr*
|
|
||||||
ConfigMgr::GetInstance() {
|
|
||||||
static YamlConfigMgr mgr;
|
|
||||||
return &mgr;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace server
|
|
||||||
} // namespace milvus
|
|
|
@ -17,42 +17,28 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ConfigNode.h"
|
|
||||||
#include "utils/Error.h"
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "ConfigNode.h"
|
||||||
|
#include "utils/Status.h"
|
||||||
|
|
||||||
namespace milvus {
|
namespace milvus {
|
||||||
namespace server {
|
namespace server {
|
||||||
|
|
||||||
// this class can parse nested config file and return config item
|
|
||||||
// config file example(yaml style)
|
|
||||||
// AAA: 1
|
|
||||||
// BBB:
|
|
||||||
// CCC: hello
|
|
||||||
// DDD: 23.5
|
|
||||||
//
|
|
||||||
// usage
|
|
||||||
// const ConfigMgr* mgr = ConfigMgr::GetInstance();
|
|
||||||
// const ConfigNode& node = mgr->GetRootNode();
|
|
||||||
// std::string val = node.GetValue("AAA"); // return '1'
|
|
||||||
// const ConfigNode& child = node.GetChild("BBB");
|
|
||||||
// val = child.GetValue("CCC"); //return 'hello'
|
|
||||||
|
|
||||||
class ConfigMgr {
|
class ConfigMgr {
|
||||||
public:
|
public:
|
||||||
static ConfigMgr*
|
virtual Status
|
||||||
GetInstance();
|
|
||||||
|
|
||||||
virtual ErrorCode
|
|
||||||
LoadConfigFile(const std::string& filename) = 0;
|
LoadConfigFile(const std::string& filename) = 0;
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
Print() const = 0; // will be deleted
|
Print() const = 0; // will be deleted
|
||||||
|
|
||||||
virtual std::string
|
virtual std::string
|
||||||
DumpString() const = 0;
|
DumpString() const = 0;
|
||||||
|
|
||||||
virtual const ConfigNode&
|
virtual const ConfigNode&
|
||||||
GetRootNode() const = 0;
|
GetRootNode() const = 0;
|
||||||
|
|
||||||
virtual ConfigNode&
|
virtual ConfigNode&
|
||||||
GetRootNode() = 0;
|
GetRootNode() = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,29 +18,20 @@
|
||||||
#include "config/YamlConfigMgr.h"
|
#include "config/YamlConfigMgr.h"
|
||||||
#include "utils/Log.h"
|
#include "utils/Log.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
namespace milvus {
|
namespace milvus {
|
||||||
namespace server {
|
namespace server {
|
||||||
|
|
||||||
ErrorCode
|
Status
|
||||||
YamlConfigMgr::LoadConfigFile(const std::string& filename) {
|
YamlConfigMgr::LoadConfigFile(const std::string& filename) {
|
||||||
struct stat directoryStat;
|
|
||||||
int statOK = stat(filename.c_str(), &directoryStat);
|
|
||||||
if (statOK != 0) {
|
|
||||||
SERVER_LOG_ERROR << "File not found: " << filename;
|
|
||||||
return SERVER_UNEXPECTED_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
node_ = YAML::LoadFile(filename);
|
node_ = YAML::LoadFile(filename);
|
||||||
LoadConfigNode(node_, config_);
|
LoadConfigNode(node_, config_);
|
||||||
} catch (YAML::Exception& e) {
|
} catch (YAML::Exception& e) {
|
||||||
SERVER_LOG_ERROR << "Failed to load config file: " << std::string(e.what());
|
std::string str = "Exception: load config file fail: " + std::string(e.what());
|
||||||
return SERVER_UNEXPECTED_ERROR;
|
return Status(SERVER_UNEXPECTED_ERROR, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SERVER_SUCCESS;
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -17,27 +17,35 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ConfigMgr.h"
|
|
||||||
#include "ConfigNode.h"
|
|
||||||
#include "utils/Error.h"
|
|
||||||
|
|
||||||
#include <yaml-cpp/yaml.h>
|
#include <yaml-cpp/yaml.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "ConfigMgr.h"
|
||||||
|
#include "utils/Status.h"
|
||||||
|
|
||||||
namespace milvus {
|
namespace milvus {
|
||||||
namespace server {
|
namespace server {
|
||||||
|
|
||||||
class YamlConfigMgr : public ConfigMgr {
|
class YamlConfigMgr : public ConfigMgr {
|
||||||
public:
|
public:
|
||||||
virtual ErrorCode
|
static ConfigMgr*
|
||||||
|
GetInstance() {
|
||||||
|
static YamlConfigMgr mgr;
|
||||||
|
return &mgr;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual Status
|
||||||
LoadConfigFile(const std::string& filename);
|
LoadConfigFile(const std::string& filename);
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
Print() const;
|
Print() const;
|
||||||
|
|
||||||
virtual std::string
|
virtual std::string
|
||||||
DumpString() const;
|
DumpString() const;
|
||||||
|
|
||||||
virtual const ConfigNode&
|
virtual const ConfigNode&
|
||||||
GetRootNode() const;
|
GetRootNode() const;
|
||||||
|
|
||||||
virtual ConfigNode&
|
virtual ConfigNode&
|
||||||
GetRootNode();
|
GetRootNode();
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,32 @@
|
||||||
INITIALIZE_EASYLOGGINGPP
|
INITIALIZE_EASYLOGGINGPP
|
||||||
|
|
||||||
void
|
void
|
||||||
print_help(const std::string& app_name);
|
print_help(const std::string& app_name) {
|
||||||
|
std::cout << std::endl << "Usage: " << app_name << " [OPTIONS]" << std::endl << std::endl;
|
||||||
|
std::cout << " Options:" << std::endl;
|
||||||
|
std::cout << " -h --help Print this help" << std::endl;
|
||||||
|
std::cout << " -c --conf_file filename Read configuration from the file" << std::endl;
|
||||||
|
std::cout << " -d --daemon Daemonize this application" << std::endl;
|
||||||
|
std::cout << " -p --pid_file filename PID file used by daemonized app" << std::endl;
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
print_banner() {
|
||||||
|
std::cout << std::endl;
|
||||||
|
std::cout << " __ _________ _ ____ ______ " << std::endl;
|
||||||
|
std::cout << " / |/ / _/ /| | / / / / / __/ " << std::endl;
|
||||||
|
std::cout << " / /|_/ // // /_| |/ / /_/ /\\ \\ " << std::endl;
|
||||||
|
std::cout << " /_/ /_/___/____/___/\\____/___/ " << std::endl;
|
||||||
|
std::cout << std::endl;
|
||||||
|
std::cout << "Welcome to use Milvus by Zilliz!" << std::endl;
|
||||||
|
std::cout << "Milvus " << BUILD_TYPE << " version: v" << MILVUS_VERSION << ", built at " << BUILD_TIME << std::endl;
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char* argv[]) {
|
main(int argc, char* argv[]) {
|
||||||
std::cout << std::endl << "Welcome to use Milvus by Zilliz!" << std::endl;
|
print_banner();
|
||||||
std::cout << "Milvus " << BUILD_TYPE << " version: v" << MILVUS_VERSION << " built at " << BUILD_TIME << std::endl;
|
|
||||||
|
|
||||||
static struct option long_options[] = {{"conf_file", required_argument, nullptr, 'c'},
|
static struct option long_options[] = {{"conf_file", required_argument, nullptr, 'c'},
|
||||||
{"log_conf_file", required_argument, nullptr, 'l'},
|
{"log_conf_file", required_argument, nullptr, 'l'},
|
||||||
|
@ -53,10 +73,12 @@ main(int argc, char* argv[]) {
|
||||||
std::string pid_filename;
|
std::string pid_filename;
|
||||||
std::string app_name = argv[0];
|
std::string app_name = argv[0];
|
||||||
|
|
||||||
|
milvus::server::Server& server = milvus::server::Server::GetInstance();
|
||||||
|
milvus::Status s;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
print_help(app_name);
|
print_help(app_name);
|
||||||
std::cout << "Milvus server exit..." << std::endl;
|
goto FAIL;
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int value;
|
int value;
|
||||||
|
@ -106,23 +128,21 @@ main(int argc, char* argv[]) {
|
||||||
signal(SIGUSR2, milvus::server::SignalUtil::HandleSignal);
|
signal(SIGUSR2, milvus::server::SignalUtil::HandleSignal);
|
||||||
signal(SIGTERM, milvus::server::SignalUtil::HandleSignal);
|
signal(SIGTERM, milvus::server::SignalUtil::HandleSignal);
|
||||||
|
|
||||||
milvus::server::Server& server = milvus::server::Server::GetInstance();
|
|
||||||
server.Init(start_daemonized, pid_filename, config_filename, log_config_file);
|
server.Init(start_daemonized, pid_filename, config_filename, log_config_file);
|
||||||
server.Start();
|
|
||||||
|
s = server.Start();
|
||||||
|
if (s.ok()) {
|
||||||
|
std::cout << "Milvus server start successfully." << std::endl;
|
||||||
|
} else {
|
||||||
|
goto FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
/* wait signal */
|
/* wait signal */
|
||||||
pause();
|
pause();
|
||||||
|
|
||||||
return 0;
|
return EXIT_SUCCESS;
|
||||||
}
|
|
||||||
|
|
||||||
void
|
FAIL:
|
||||||
print_help(const std::string& app_name) {
|
std::cout << "Milvus server exit..." << std::endl;
|
||||||
std::cout << std::endl << "Usage: " << app_name << " [OPTIONS]" << std::endl << std::endl;
|
return EXIT_FAILURE;
|
||||||
std::cout << " Options:" << std::endl;
|
|
||||||
std::cout << " -h --help Print this help" << std::endl;
|
|
||||||
std::cout << " -c --conf_file filename Read configuration from the file" << std::endl;
|
|
||||||
std::cout << " -d --daemon Daemonize this application" << std::endl;
|
|
||||||
std::cout << " -p --pid_file filename PID file used by daemonized app" << std::endl;
|
|
||||||
std::cout << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,8 +160,8 @@ XSearchTask::Load(LoadType type, uint8_t device_id) {
|
||||||
|
|
||||||
size_t file_size = index_engine_->PhysicalSize();
|
size_t file_size = index_engine_->PhysicalSize();
|
||||||
|
|
||||||
std::string info = "Load file id:" + std::to_string(file_->id_) +
|
std::string info = "Load file id:" + std::to_string(file_->id_) + " file type:" +
|
||||||
" file type:" + std::to_string(file_->file_type_) + " size:" + std::to_string(file_size) +
|
std::to_string(file_->file_type_) + " size:" + std::to_string(file_size) +
|
||||||
" bytes from location: " + file_->location_ + " totally cost";
|
" bytes from location: " + file_->location_ + " totally cost";
|
||||||
double span = rc.ElapseFromBegin(info);
|
double span = rc.ElapseFromBegin(info);
|
||||||
// for (auto &context : search_contexts_) {
|
// for (auto &context : search_contexts_) {
|
||||||
|
|
|
@ -15,18 +15,14 @@
|
||||||
// specific language governing permissions and limitations
|
// specific language governing permissions and limitations
|
||||||
// under the License.
|
// under the License.
|
||||||
|
|
||||||
#include "server/Config.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "config/ConfigMgr.h"
|
#include "config/YamlConfigMgr.h"
|
||||||
|
#include "server/Config.h"
|
||||||
#include "utils/CommonUtil.h"
|
#include "utils/CommonUtil.h"
|
||||||
#include "utils/ValidationUtil.h"
|
#include "utils/ValidationUtil.h"
|
||||||
|
|
||||||
|
@ -44,26 +40,24 @@ Config::GetInstance() {
|
||||||
Status
|
Status
|
||||||
Config::LoadConfigFile(const std::string& filename) {
|
Config::LoadConfigFile(const std::string& filename) {
|
||||||
if (filename.empty()) {
|
if (filename.empty()) {
|
||||||
std::cerr << "ERROR: need specify config file" << std::endl;
|
return Status(SERVER_UNEXPECTED_ERROR, "No specified config file");
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
struct stat dirStat;
|
|
||||||
int statOK = stat(filename.c_str(), &dirStat);
|
struct stat file_stat;
|
||||||
if (statOK != 0) {
|
if (stat(filename.c_str(), &file_stat) != 0) {
|
||||||
std::cerr << "ERROR: Config file not exist: " << filename << std::endl;
|
std::string str = "Config file not exist: " + filename;
|
||||||
exit(1);
|
return Status(SERVER_FILE_NOT_FOUND, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ConfigMgr* mgr = const_cast<ConfigMgr*>(ConfigMgr::GetInstance());
|
ConfigMgr* mgr = YamlConfigMgr::GetInstance();
|
||||||
ErrorCode err = mgr->LoadConfigFile(filename);
|
Status s = mgr->LoadConfigFile(filename);
|
||||||
if (err != 0) {
|
if (!s.ok()) {
|
||||||
std::cerr << "Server failed to load config file: " << filename << std::endl;
|
return s;
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
} catch (YAML::Exception& e) {
|
} catch (YAML::Exception& e) {
|
||||||
std::cerr << "Server failed to load config file: " << filename << std::endl;
|
std::string str = "Exception occurs when loading config file: " + filename;
|
||||||
exit(1);
|
return Status(SERVER_UNEXPECTED_ERROR, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
|
@ -632,7 +626,7 @@ Config::CheckResourceConfigPool(const std::vector<std::string>& value) {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ConfigNode&
|
ConfigNode&
|
||||||
Config::GetConfigNode(const std::string& name) {
|
Config::GetConfigNode(const std::string& name) {
|
||||||
ConfigMgr* mgr = ConfigMgr::GetInstance();
|
ConfigMgr* mgr = YamlConfigMgr::GetInstance();
|
||||||
ConfigNode& root_node = mgr->GetRootNode();
|
ConfigNode& root_node = mgr->GetRootNode();
|
||||||
return root_node.GetChild(name);
|
return root_node.GetChild(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <yaml-cpp/yaml.h>
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
@ -110,13 +109,10 @@ class Config {
|
||||||
private:
|
private:
|
||||||
ConfigNode&
|
ConfigNode&
|
||||||
GetConfigNode(const std::string& name);
|
GetConfigNode(const std::string& name);
|
||||||
|
|
||||||
Status
|
Status
|
||||||
GetConfigValueInMem(const std::string& parent_key, const std::string& child_key, std::string& value);
|
GetConfigValueInMem(const std::string& parent_key, const std::string& child_key, std::string& value);
|
||||||
|
|
||||||
void
|
void
|
||||||
SetConfigValueInMem(const std::string& parent_key, const std::string& child_key, const std::string& value);
|
SetConfigValueInMem(const std::string& parent_key, const std::string& child_key, const std::string& value);
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintConfigSection(const std::string& config_node_name);
|
PrintConfigSection(const std::string& config_node_name);
|
||||||
|
|
||||||
|
|
|
@ -15,19 +15,19 @@
|
||||||
// specific language governing permissions and limitations
|
// specific language governing permissions and limitations
|
||||||
// under the License.
|
// under the License.
|
||||||
|
|
||||||
#include "server/DBWrapper.h"
|
|
||||||
#include "Config.h"
|
|
||||||
#include "db/DBFactory.h"
|
|
||||||
#include "utils/CommonUtil.h"
|
|
||||||
#include "utils/Log.h"
|
|
||||||
#include "utils/StringHelpFunctions.h"
|
|
||||||
|
|
||||||
#include <faiss/utils.h>
|
#include <faiss/utils.h>
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "db/DBFactory.h"
|
||||||
|
#include "server/Config.h"
|
||||||
|
#include "server/DBWrapper.h"
|
||||||
|
#include "utils/CommonUtil.h"
|
||||||
|
#include "utils/Log.h"
|
||||||
|
#include "utils/StringHelpFunctions.h"
|
||||||
|
|
||||||
namespace milvus {
|
namespace milvus {
|
||||||
namespace server {
|
namespace server {
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ Status
|
||||||
DBWrapper::StartService() {
|
DBWrapper::StartService() {
|
||||||
Config& config = Config::GetInstance();
|
Config& config = Config::GetInstance();
|
||||||
Status s;
|
Status s;
|
||||||
|
|
||||||
// db config
|
// db config
|
||||||
engine::DBOptions opt;
|
engine::DBOptions opt;
|
||||||
|
|
||||||
s = config.GetDBConfigBackendUrl(opt.meta_.backend_uri_);
|
s = config.GetDBConfigBackendUrl(opt.meta_.backend_uri_);
|
||||||
if (!s.ok()) {
|
if (!s.ok()) {
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -17,12 +17,11 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "db/DB.h"
|
#include "db/DB.h"
|
||||||
#include "utils/Status.h"
|
#include "utils/Status.h"
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace milvus {
|
namespace milvus {
|
||||||
namespace server {
|
namespace server {
|
||||||
|
|
||||||
|
|
|
@ -15,21 +15,15 @@
|
||||||
// specific language governing permissions and limitations
|
// specific language governing permissions and limitations
|
||||||
// under the License.
|
// under the License.
|
||||||
|
|
||||||
#include "server/Server.h"
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <csignal>
|
|
||||||
#include <thread>
|
|
||||||
//#include <numaif.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "DBWrapper.h"
|
|
||||||
#include "metrics/Metrics.h"
|
#include "metrics/Metrics.h"
|
||||||
#include "scheduler/SchedInst.h"
|
#include "scheduler/SchedInst.h"
|
||||||
#include "server/Config.h"
|
#include "server/Config.h"
|
||||||
|
#include "server/DBWrapper.h"
|
||||||
|
#include "server/Server.h"
|
||||||
#include "server/grpc_impl/GrpcServer.h"
|
#include "server/grpc_impl/GrpcServer.h"
|
||||||
#include "utils/Log.h"
|
#include "utils/Log.h"
|
||||||
#include "utils/LogUtil.h"
|
#include "utils/LogUtil.h"
|
||||||
|
@ -143,7 +137,7 @@ Server::Daemonize() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
Status
|
||||||
Server::Start() {
|
Server::Start() {
|
||||||
if (daemonized_ != 0) {
|
if (daemonized_ != 0) {
|
||||||
Daemonize();
|
Daemonize();
|
||||||
|
@ -151,18 +145,19 @@ Server::Start() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/* Read config file */
|
/* Read config file */
|
||||||
if (LoadConfig() != SERVER_SUCCESS) {
|
Status s = LoadConfig();
|
||||||
std::cerr << "Milvus server fail to load config file" << std::endl;
|
if (!s.ok()) {
|
||||||
return;
|
std::cerr << "ERROR: Milvus server fail to load config file" << std::endl;
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* log path is defined in Config file, so InitLog must be called after LoadConfig */
|
/* log path is defined in Config file, so InitLog must be called after LoadConfig */
|
||||||
Config& config = Config::GetInstance();
|
Config& config = Config::GetInstance();
|
||||||
std::string time_zone;
|
std::string time_zone;
|
||||||
Status s = config.GetServerConfigTimeZone(time_zone);
|
s = config.GetServerConfigTimeZone(time_zone);
|
||||||
if (!s.ok()) {
|
if (!s.ok()) {
|
||||||
std::cerr << "Fail to get server config timezone" << std::endl;
|
std::cerr << "Fail to get server config timezone" << std::endl;
|
||||||
return;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time_zone.length() == 3) {
|
if (time_zone.length() == 3) {
|
||||||
|
@ -179,8 +174,7 @@ Server::Start() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setenv("TZ", time_zone.c_str(), 1) != 0) {
|
if (setenv("TZ", time_zone.c_str(), 1) != 0) {
|
||||||
std::cerr << "Fail to setenv" << std::endl;
|
return Status(SERVER_UNEXPECTED_ERROR, "Fail to setenv");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
tzset();
|
tzset();
|
||||||
|
|
||||||
|
@ -190,9 +184,10 @@ Server::Start() {
|
||||||
server::SystemInfo::GetInstance().Init();
|
server::SystemInfo::GetInstance().Init();
|
||||||
|
|
||||||
StartService();
|
StartService();
|
||||||
std::cout << "Milvus server start successfully." << std::endl;
|
return Status::OK();
|
||||||
} catch (std::exception& ex) {
|
} catch (std::exception& ex) {
|
||||||
std::cerr << "Milvus server encounter exception: " << ex.what();
|
std::string str = "Milvus server encounter exception: " + std::string(ex.what());
|
||||||
|
return Status(SERVER_UNEXPECTED_ERROR, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,12 +199,12 @@ Server::Stop() {
|
||||||
if (pid_fd_ != -1) {
|
if (pid_fd_ != -1) {
|
||||||
int ret = lockf(pid_fd_, F_ULOCK, 0);
|
int ret = lockf(pid_fd_, F_ULOCK, 0);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
std::cerr << "Can't lock file: " << strerror(errno) << std::endl;
|
std::cerr << "ERROR: Can't lock file: " << strerror(errno) << std::endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
ret = close(pid_fd_);
|
ret = close(pid_fd_);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
std::cerr << "Can't close file: " << strerror(errno) << std::endl;
|
std::cerr << "ERROR: Can't close file: " << strerror(errno) << std::endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,31 +213,31 @@ Server::Stop() {
|
||||||
if (!pid_filename_.empty()) {
|
if (!pid_filename_.empty()) {
|
||||||
int ret = unlink(pid_filename_.c_str());
|
int ret = unlink(pid_filename_.c_str());
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
std::cerr << "Can't unlink file: " << strerror(errno) << std::endl;
|
std::cerr << "ERROR: Can't unlink file: " << strerror(errno) << std::endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StopService();
|
StopService();
|
||||||
|
|
||||||
std::cerr << "Milvus server is closed!" << std::endl;
|
std::cerr << "Milvus server exit..." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode
|
Status
|
||||||
Server::LoadConfig() {
|
Server::LoadConfig() {
|
||||||
Config& config = Config::GetInstance();
|
Config& config = Config::GetInstance();
|
||||||
Status s = config.LoadConfigFile(config_filename_);
|
Status s = config.LoadConfigFile(config_filename_);
|
||||||
if (!s.ok()) {
|
if (!s.ok()) {
|
||||||
std::cerr << "Failed to load config file: " << config_filename_ << std::endl;
|
std::cerr << s.message() << std::endl;
|
||||||
exit(0);
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = config.ValidateConfig();
|
s = config.ValidateConfig();
|
||||||
if (!s.ok()) {
|
if (!s.ok()) {
|
||||||
std::cerr << "Config check fail: " << s.message() << std::endl;
|
std::cerr << "Config check fail: " << s.message() << std::endl;
|
||||||
exit(0);
|
return s;
|
||||||
}
|
}
|
||||||
return SERVER_SUCCESS;
|
return milvus::Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -17,10 +17,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "utils/Status.h"
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "utils/Status.h"
|
||||||
|
|
||||||
namespace milvus {
|
namespace milvus {
|
||||||
namespace server {
|
namespace server {
|
||||||
|
@ -34,7 +32,7 @@ class Server {
|
||||||
Init(int64_t daemonized, const std::string& pid_filename, const std::string& config_filename,
|
Init(int64_t daemonized, const std::string& pid_filename, const std::string& config_filename,
|
||||||
const std::string& log_config_file);
|
const std::string& log_config_file);
|
||||||
|
|
||||||
void
|
Status
|
||||||
Start();
|
Start();
|
||||||
void
|
void
|
||||||
Stop();
|
Stop();
|
||||||
|
@ -46,7 +44,7 @@ class Server {
|
||||||
void
|
void
|
||||||
Daemonize();
|
Daemonize();
|
||||||
|
|
||||||
ErrorCode
|
Status
|
||||||
LoadConfig();
|
LoadConfig();
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue