Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion engine/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void RunServer(std::optional<std::string> host, std::optional<int> port,
CTL_WRN("Require API key to access /v1/configs");
return false;
}

// If API key is not set, skip validation
if (api_keys.empty()) {
return true;
Expand Down Expand Up @@ -383,6 +383,7 @@ void print_help() {
"~/cortexcpp)\n";
std::cout << " --host Host name (default: 127.0.0.1)\n";
std::cout << " --port Port number (default: 39281)\n";
std::cout << " --api_configs Keys to acess API endpoints\n";
std::cout << " --ignore_cout Ignore cout output\n";
std::cout << " --loglevel Set log level\n";

Expand Down Expand Up @@ -411,6 +412,7 @@ int main(int argc, char* argv[]) {

std::optional<std::string> server_host;
std::optional<int> server_port;
std::optional<std::string> api_keys;
bool ignore_cout_log = false;
#if defined(_WIN32)
for (int i = 0; i < argc; i++) {
Expand All @@ -427,6 +429,8 @@ int main(int argc, char* argv[]) {
server_host = cortex::wc::WstringToUtf8(argv[i + 1]);
} else if (command == L"--port") {
server_port = std::stoi(argv[i + 1]);
} else if (command == L"--api_keys") {
api_keys = cortex::wc::WstringToUtf8(argv[i + 1]);
} else if (command == L"--ignore_cout") {
ignore_cout_log = true;
} else if (command == L"--loglevel") {
Expand All @@ -447,6 +451,8 @@ int main(int argc, char* argv[]) {
server_host = argv[i + 1];
} else if (strcmp(argv[i], "--port") == 0) {
server_port = std::stoi(argv[i + 1]);
} else if (strcmp(argv[i], "--api_keys") == 0) {
api_keys = argv[i + 1];
} else if (strcmp(argv[i], "--ignore_cout") == 0) {
ignore_cout_log = true;
} else if (strcmp(argv[i], "--loglevel") == 0) {
Expand Down Expand Up @@ -482,6 +488,15 @@ int main(int argc, char* argv[]) {
}
}

if (api_keys) {
auto config = file_manager_utils::GetCortexConfig();
config.apiKeys = string_utils::SplitBy(*api_keys, ",");
auto result = file_manager_utils::UpdateCortexConfig(config);
if (result.has_error()) {
CTL_ERR(result.error());
}
}

// check if migration is needed
if (auto res = cortex::migr::MigrationManager(
cortex::db::Database::GetInstance().db())
Expand Down
Loading