Skip to content

Commit d182544

Browse files
committed
server : minor
1 parent 4a1c05c commit d182544

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

tools/server/server-models.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "download.h"
55

66
#include <cpp-httplib/httplib.h>
7+
#include <sheredom/subprocess.h>
78

89
#include <functional>
910
#include <thread>
@@ -12,7 +13,6 @@
1213
#include <cstring>
1314
#include <atomic>
1415
#include <chrono>
15-
#include <unordered_set>
1616

1717
#ifdef _WIN32
1818
#include <winsock2.h>
@@ -84,7 +84,7 @@ static std::vector<local_model> list_local_models(const std::string & dir) {
8484
}
8585

8686
std::vector<local_model> models;
87-
auto scan_subdir = [&models](const std::string & subdir_path, const std::string name) {
87+
auto scan_subdir = [&models](const std::string & subdir_path, const std::string & name) {
8888
auto files = fs_list(subdir_path, false);
8989
common_file_info model_file;
9090
common_file_info first_shard_file;
@@ -292,6 +292,7 @@ static std::vector<char *> to_char_ptr_array(const std::vector<std::string> & ve
292292
std::vector<server_model_meta> server_models::get_all_meta() {
293293
std::lock_guard<std::mutex> lk(mutex);
294294
std::vector<server_model_meta> result;
295+
result.reserve(mapping.size());
295296
for (const auto & [name, inst] : mapping) {
296297
result.push_back(inst.meta);
297298
}
@@ -363,7 +364,7 @@ void server_models::load(const std::string & name, bool auto_load) {
363364

364365
inst.subproc = std::make_shared<subprocess_s>();
365366
{
366-
std::string exec_path = get_server_exec_path().string();
367+
//std::string exec_path = get_server_exec_path().string();
367368
SRV_INF("spawning server instance with name=%s on port %d\n", inst.meta.name.c_str(), inst.meta.port);
368369

369370
std::vector<std::string> child_args;

tools/server/server-models.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
#include "common.h"
44
#include "server-http.h"
55

6-
#include <sheredom/subprocess.h>
7-
8-
#include <queue>
96
#include <mutex>
107
#include <condition_variable>
118
#include <functional>
@@ -30,13 +27,14 @@ enum server_model_status {
3027
static server_model_status server_model_status_from_string(const std::string & status_str) {
3128
if (status_str == "unloaded") {
3229
return SERVER_MODEL_STATUS_UNLOADED;
33-
} else if (status_str == "loading") {
30+
}
31+
if (status_str == "loading") {
3432
return SERVER_MODEL_STATUS_LOADING;
35-
} else if (status_str == "loaded") {
33+
}
34+
if (status_str == "loaded") {
3635
return SERVER_MODEL_STATUS_LOADED;
37-
} else {
38-
throw std::runtime_error("invalid server model status");
3936
}
37+
throw std::runtime_error("invalid server model status");
4038
}
4139

4240
static std::string server_model_status_to_string(server_model_status status) {
@@ -68,6 +66,8 @@ struct server_model_meta {
6866
}
6967
};
7068

69+
struct subprocess_s;
70+
7171
struct server_models {
7272
private:
7373
struct instance_t {

0 commit comments

Comments
 (0)