Skip to content

Commit

Permalink
chore: update cortexrc fields
Browse files Browse the repository at this point in the history
namchuai committed Sep 9, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent a2e54ce commit 24166e4
Showing 3 changed files with 12 additions and 13 deletions.
8 changes: 4 additions & 4 deletions engine/main.cc
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@

void RunServer() {
auto config = file_manager_utils::GetCortexConfig();
LOG_INFO << "Host: " << config.host << " Port: " << config.port << "\n";
LOG_INFO << "Host: " << config.apiServerHost << " Port: " << config.apiServerPort << "\n";

// Create logs/ folder and setup log to file
std::filesystem::create_directory(cortex_utils::logs_folder);
@@ -66,10 +66,10 @@ void RunServer() {
LOG_INFO << "cortex.cpp version: undefined";
#endif

LOG_INFO << "Server started, listening at: " << config.host << ":"
<< config.port;
LOG_INFO << "Server started, listening at: " << config.apiServerHost << ":"
<< config.apiServerPort;
LOG_INFO << "Please load your model";
drogon::app().addListener(config.host, std::stoi(config.port));
drogon::app().addListener(config.apiServerHost, std::stoi(config.apiServerPort));
drogon::app().setThreadNum(drogon_thread_num);
LOG_INFO << "Number of thread is:" << drogon::app().getThreadNum();

13 changes: 6 additions & 7 deletions engine/utils/config_yaml_utils.h
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@
namespace config_yaml_utils {
struct CortexConfig {
std::string dataFolderPath;
std::string host;
std::string port;
std::string apiServerHost;
std::string apiServerPort;
};

const std::string kCortexFolderName = "cortexcpp";
@@ -28,8 +28,8 @@ inline void DumpYamlConfig(const CortexConfig& config,
}
YAML::Node node;
node["dataFolderPath"] = config.dataFolderPath;
node["host"] = config.host;
node["port"] = config.port;
node["apiServerHost"] = config.apiServerHost;
node["apiServerPort"] = config.apiServerPort;

out_file << node;
out_file.close();
@@ -50,8 +50,8 @@ inline CortexConfig FromYaml(const std::string& path,
auto node = YAML::LoadFile(config_file_path.string());
CortexConfig config = {
.dataFolderPath = node["dataFolderPath"].as<std::string>(),
.host = node["host"].as<std::string>(),
.port = node["port"].as<std::string>(),
.apiServerHost = node["apiServerHost"].as<std::string>(),
.apiServerPort = node["apiServerPort"].as<std::string>(),
};
return config;
} catch (const YAML::BadFile& e) {
@@ -60,5 +60,4 @@ inline CortexConfig FromYaml(const std::string& path,
}
}


} // namespace config_yaml_utils
4 changes: 2 additions & 2 deletions engine/utils/file_manager_utils.h
Original file line number Diff line number Diff line change
@@ -136,8 +136,8 @@ inline void CreateConfigFileIfNotExist() {

auto config = config_yaml_utils::CortexConfig{
.dataFolderPath = defaultDataFolderPath.string(),
.host = config_yaml_utils::kDefaultHost,
.port = config_yaml_utils::kDefaultPort,
.apiServerHost = config_yaml_utils::kDefaultHost,
.apiServerPort = config_yaml_utils::kDefaultPort,
};
DumpYamlConfig(config, config_path.string());
}

0 comments on commit 24166e4

Please sign in to comment.