Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 8c4ca06

Browse files
committed
fix: wait for child process up
1 parent bb5cc35 commit 8c4ca06

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

engine/extensions/local-engine/local_engine.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,16 +492,17 @@ void LocalEngine::HandleEmbedding(std::shared_ptr<Json::Value> json_body,
492492
void LocalEngine::LoadModel(std::shared_ptr<Json::Value> json_body,
493493
http_callback&& callback) {
494494
CTL_INF("Start loading model");
495-
auto wait_for_server_up = [](const std::string& host, int port) {
495+
auto wait_for_server_up = [this](const std::string& model,
496+
const std::string& host, int port) {
496497
auto url = url_parser::Url{
497498
.protocol = "http",
498499
.host = host + ":" + std::to_string(port),
499500
.pathParams = {"health"},
500501
};
501-
for (size_t i = 0; i < 10; i++) {
502+
while (server_map_.find(model) != server_map_.end()) {
502503
auto res = curl_utils::SimpleGet(url.ToFullPath());
503504
if (res.has_error()) {
504-
LOG_INFO << "Wait for server up: " << i;
505+
LOG_INFO << "Wait for server up ..";
505506
std::this_thread::sleep_for(std::chrono::seconds(1));
506507
} else {
507508
return true;
@@ -560,7 +561,7 @@ void LocalEngine::LoadModel(std::shared_ptr<Json::Value> json_body,
560561
}
561562

562563
s.process_info = result.value();
563-
if (wait_for_server_up(s.host, s.port)) {
564+
if (wait_for_server_up(model_id, s.host, s.port)) {
564565
Json::Value response;
565566
response["status"] = "Model loaded successfully with pid: " +
566567
std::to_string(s.process_info.pid);

0 commit comments

Comments
 (0)