Skip to content

Commit

Permalink
Merge pull request #1172 from janhq/j/update-cortexrc-fields
Browse files Browse the repository at this point in the history
chore: update `.cortexrc` fields
  • Loading branch information
namchuai authored Sep 9, 2024
2 parents a2e54ce + 24166e4 commit d31c7a9
Show file tree
Hide file tree
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
Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand Down
13 changes: 6 additions & 7 deletions engine/utils/config_yaml_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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();
Expand All @@ -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) {
Expand All @@ -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
Expand Up @@ -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());
}
Expand Down

0 comments on commit d31c7a9

Please sign in to comment.