Skip to content

Commit

Permalink
Merge pull request #1687 from janhq/j/update-user-defined-engine-path
Browse files Browse the repository at this point in the history
fix: support user defined engine path
  • Loading branch information
namchuai authored Nov 15, 2024
2 parents 11aaf19 + 481a092 commit 3bf5f87
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions engine/services/engine_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -773,26 +773,29 @@ cpp::result<void, std::string> EngineService::LoadEngine(
auto selected_engine_variant = GetDefaultEngineVariant(ne);

if (selected_engine_variant.has_error()) {
// TODO: namh need to fallback
return cpp::fail(selected_engine_variant.error());
}

CTL_INF("Selected engine variant: "
<< json_helper::DumpJsonString(selected_engine_variant->ToJson()));

auto user_defined_engine_path = getenv("ENGINE_PATH");
CTL_DBG("user defined engine path: " << user_defined_engine_path);
const std::filesystem::path engine_dir_path = [&] {
if (user_defined_engine_path != nullptr) {
// for backward compatible
return std::filesystem::path(user_defined_engine_path +
GetEnginePath(ne));
GetEnginePath(ne)) /
selected_engine_variant->variant /
selected_engine_variant->version;
} else {
return file_manager_utils::GetEnginesContainerPath() / ne /
selected_engine_variant->variant /
selected_engine_variant->version;
}
}();

CTL_DBG("Engine path: " << engine_dir_path.string());

if (!std::filesystem::exists(engine_dir_path)) {
CTL_ERR("Directory " + engine_dir_path.string() + " is not exist!");
return cpp::fail("Directory " + engine_dir_path.string() +
Expand Down

0 comments on commit 3bf5f87

Please sign in to comment.