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
29 changes: 22 additions & 7 deletions engine/controllers/command_line_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,30 @@ bool CommandLineParser::SetupCommand(int argc, char** argv) {
return true;
}

// Check new update, only check for stable release for now
// Check new update
#ifdef CORTEX_CPP_VERSION
if (cml_data_.check_upd) {
if (auto latest_version = commands::CheckNewUpdate(commands::kTimeoutCheckUpdate);
latest_version.has_value() && *latest_version != CORTEX_CPP_VERSION) {
CLI_LOG("\nA new release of cortex is available: "
<< CORTEX_CPP_VERSION << " -> " << *latest_version);
CLI_LOG("To upgrade, run: " << commands::GetRole()
<< commands::GetCortexBinary() << " update");
// TODO(sang) find a better way to handle
// This is an extremely ungly way to deal with connection
// hang when network down
std::atomic<bool> done = false;
std::thread t([&]() {
if (auto latest_version =
commands::CheckNewUpdate(commands::kTimeoutCheckUpdate);
latest_version.has_value() && *latest_version != CORTEX_CPP_VERSION) {
CLI_LOG("\nA new release of cortex is available: "
<< CORTEX_CPP_VERSION << " -> " << *latest_version);
CLI_LOG("To upgrade, run: " << commands::GetRole()
<< commands::GetCortexBinary()
<< " update");
}
done = true;
});
// Do not wait for http connection timeout
t.detach();
int retry = 10;
while (!done && retry--) {
std::this_thread::sleep_for(commands::kTimeoutCheckUpdate / 10);
}
}
#endif
Expand Down
Loading