-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: should check model status before start it (#1277)
* fix: check model status before start * fix: read timeout for checking update * fix: only set logger for engine once
- Loading branch information
1 parent
d9c5b41
commit 3f7d3ec
Showing
7 changed files
with
81 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "model_status_cmd.h" | ||
#include "config/yaml_config.h" | ||
#include "httplib.h" | ||
#include "nlohmann/json.hpp" | ||
#include "utils/logging_utils.h" | ||
|
||
namespace commands { | ||
bool ModelStatusCmd::IsLoaded(const std::string& host, int port, | ||
const config::ModelConfig& mc) { | ||
httplib::Client cli(host + ":" + std::to_string(port)); | ||
nlohmann::json json_data; | ||
json_data["model"] = mc.name; | ||
json_data["engine"] = mc.engine; | ||
|
||
auto data_str = json_data.dump(); | ||
|
||
auto res = cli.Post("/inferences/server/modelstatus", httplib::Headers(), | ||
data_str.data(), data_str.size(), "application/json"); | ||
if (res) { | ||
if (res->status == httplib::StatusCode::OK_200) { | ||
return true; | ||
} | ||
} else { | ||
auto err = res.error(); | ||
CTL_WRN("HTTP error: " << httplib::to_string(err)); | ||
return false; | ||
} | ||
|
||
return false; | ||
} | ||
} // namespace commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
#include <string> | ||
#include "config/yaml_config.h" | ||
|
||
namespace commands { | ||
|
||
class ModelStatusCmd { | ||
public: | ||
bool IsLoaded(const std::string& host, int port, | ||
const config::ModelConfig& mc); | ||
}; | ||
} // namespace commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters