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

Commit 7c4d964

Browse files
committed
chore: cleanup
1 parent 5a68356 commit 7c4d964

File tree

5 files changed

+20
-24
lines changed

5 files changed

+20
-24
lines changed

engine/cli/command_line_parser.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ CommandLineParser::CommandLineParser()
5151
download_service_{std::make_shared<DownloadService>()},
5252
dylib_path_manager_{std::make_shared<cortex::DylibPathManager>()},
5353
db_service_{std::make_shared<DatabaseService>()},
54-
engine_service_{std::make_shared<EngineService>(
55-
download_service_, dylib_path_manager_, db_service_,
56-
std::make_shared<cortex::TaskQueue>(1, "q"))} {}
54+
engine_service_{std::make_shared<EngineService>(dylib_path_manager_)} {}
5755

5856
bool CommandLineParser::SetupCommand(int argc, char** argv) {
5957
app_.usage("Usage:\n" + commands::GetCortexBinary() +

engine/cli/commands/server_start_cmd.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,7 @@ bool ServerStartCmd::Exec(const std::string& host, int port,
106106
#else
107107
std::vector<std::string> commands;
108108
// Some engines requires to add lib search path before process being created
109-
auto download_srv = std::make_shared<DownloadService>();
110-
auto dylib_path_mng = std::make_shared<cortex::DylibPathManager>();
111-
auto db_srv = std::make_shared<DatabaseService>();
112-
EngineService(download_srv, dylib_path_mng, db_srv,
113-
std::make_shared<cortex::TaskQueue>(1, "task_queue"))
109+
EngineService(std::make_shared<cortex::DylibPathManager>())
114110
.RegisterEngineLibPath();
115111

116112
std::string p = cortex_utils::GetCurrentPath() + "/" + exe;

engine/services/engine_service.cc

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,21 +301,25 @@ cpp::result<void, std::string> EngineService::DownloadEngine(
301301
meta << "name: " << variant.value() << std::endl;
302302
meta << "version: " << selected_variant->version << std::endl;
303303
meta.close();
304-
namespace fs = std::filesystem;
305304

306-
fs::path bin_path = extract_path / "build" / "bin";
307-
if (fs::exists(bin_path)) {
308-
for (const auto& entry : fs::directory_iterator(bin_path)) {
305+
std::filesystem::path bin_path = extract_path / "build" / "bin";
306+
if (std::filesystem::exists(bin_path)) {
307+
for (const auto& entry :
308+
std::filesystem::directory_iterator(bin_path)) {
309309
if (entry.is_regular_file()) {
310-
fs::path target_file = extract_path / entry.path().filename();
311-
fs::copy_file(entry.path(), target_file,
312-
fs::copy_options::overwrite_existing);
310+
std::filesystem::path target_file =
311+
extract_path / entry.path().filename();
312+
std::filesystem::copy_file(
313+
entry.path(), target_file,
314+
std::filesystem::copy_options::overwrite_existing);
313315
}
314316
}
315317
std::filesystem::remove_all(bin_path.parent_path());
316318
}
317-
if (!fs::exists(extract_path.parent_path().parent_path() / "deps")) {
318-
fs::create_directory(extract_path.parent_path().parent_path() / "deps");
319+
if (!std::filesystem::exists(extract_path.parent_path().parent_path() /
320+
"deps")) {
321+
std::filesystem::create_directory(
322+
extract_path.parent_path().parent_path() / "deps");
319323
}
320324
std::filesystem::permissions(extract_path / kLlamaServer,
321325
std::filesystem::perms::owner_exec |

engine/services/engine_service.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class EngineService : public EngineServiceI {
6464
std::shared_ptr<cortex::TaskQueue> q_ = nullptr;
6565

6666
public:
67-
explicit EngineService(
67+
EngineService(
6868
std::shared_ptr<DownloadService> download_service,
6969
std::shared_ptr<cortex::DylibPathManager> dylib_path_manager,
7070
std::shared_ptr<DatabaseService> db_service,
@@ -77,6 +77,9 @@ class EngineService : public EngineServiceI {
7777
db_service_(db_service),
7878
q_(q) {}
7979

80+
EngineService(std::shared_ptr<cortex::DylibPathManager> dylib_path_manager)
81+
: dylib_path_manager_(dylib_path_manager) {}
82+
8083
std::vector<EngineInfo> GetEngineInfoList() const;
8184

8285
/**

engine/services/hardware_service.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,7 @@ bool HardwareService::Restart(const std::string& host, int port) {
203203
#else
204204
std::vector<std::string> commands;
205205
// Some engines requires to add lib search path before process being created
206-
auto download_srv = std::make_shared<DownloadService>();
207-
auto dylib_path_mng = std::make_shared<cortex::DylibPathManager>();
208-
auto db_srv = std::make_shared<DatabaseService>();
209-
// TODO(sang) refactor this
210-
EngineService(download_srv, dylib_path_mng, db_srv,
211-
std::make_shared<cortex::TaskQueue>(1, "task_queue"))
206+
EngineService(std::make_shared<cortex::DylibPathManager>())
212207
.RegisterEngineLibPath();
213208
std::string p = cortex_utils::GetCurrentPath() / exe;
214209
commands.push_back(p);

0 commit comments

Comments
 (0)