Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 6 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
13 changes: 11 additions & 2 deletions engine/controllers/process_manager.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
#include "process_manager.h"
#include "utils/cortex_utils.h"

#include <trantor/utils/Logger.h>
#include <cstdlib>
#include "json/json.h"
#include "utils/cortex_utils.h"

void ProcessManager::destroy(
const HttpRequestPtr& req,
std::function<void(const HttpResponsePtr&)>&& callback) {
auto res = inference_service_->GetModels(std::make_shared<Json::Value>());
// Check if there are any running models
auto running_models = std::get<1>(res);
if (!running_models.get("data", Json::Value()).empty()) {
for (const auto& model : running_models["data"]) {
std::string model_id = model["id"].asString();
model_service_->StopModel(model_id);
}
}

app().quit();
Json::Value ret;
Expand Down
10 changes: 10 additions & 0 deletions engine/controllers/process_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <drogon/HttpController.h>
#include <drogon/HttpTypes.h>
#include "services/inference_service.h"
#include "services/model_service.h"

using namespace drogon;

Expand All @@ -13,4 +15,12 @@ class ProcessManager : public drogon::HttpController<ProcessManager, false> {

void destroy(const HttpRequestPtr& req,
std::function<void(const HttpResponsePtr&)>&& callback);

ProcessManager(std::shared_ptr<InferenceService> inference_service,
std::shared_ptr<ModelService> model_service)
: inference_service_(inference_service), model_service_(model_service) {}

private:
std::shared_ptr<InferenceService> inference_service_;
std::shared_ptr<ModelService> model_service_;
};
2 changes: 1 addition & 1 deletion engine/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void RunServer(std::optional<std::string> host, std::optional<int> port,
auto model_ctl = std::make_shared<Models>(db_service, model_service,
engine_service, model_src_svc);
auto event_ctl = std::make_shared<Events>(event_queue_ptr);
auto pm_ctl = std::make_shared<ProcessManager>();
auto pm_ctl = std::make_shared<ProcessManager>(inference_svc, model_service);
auto hw_ctl = std::make_shared<Hardware>(engine_service, hw_service);
auto server_ctl =
std::make_shared<inferences::server>(inference_svc, engine_service);
Expand Down
5 changes: 3 additions & 2 deletions engine/services/model_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,9 @@ ModelService::DownloadModelFromCortexsoAsync(
pyvenv_cfg.close();
// Add executable permission to python

set_permission_utils::SetExecutePermissionsRecursive(
venv_path );

set_permission_utils::SetExecutePermissionsRecursive(venv_path);


} else {
CTL_ERR("Failed to extract venv.zip");
Expand Down