server: (router) lazy-load startup_models after main setup

This commit is contained in:
Xuan Son Nguyen
2026-08-20 01:56:18 +02:00
parent d59d455fd8
commit c47322cc8a
3 changed files with 34 additions and 4 deletions
+16 -4
View File
@@ -685,11 +685,10 @@ void server_models::load_models() {
models_to_load.size(), base_params.models_max));
}
// to be lazy-loaded after main() setup phase is completed
startup_models = std::move(models_to_load);
lk.unlock();
for (const auto & name : models_to_load) {
SRV_INF("(startup) loading model %s\n", name.c_str());
load(name);
}
} else {
// RELOAD: diff the new preset list against the current mapping and reconcile
is_reloading = true;
@@ -877,6 +876,19 @@ void server_models::load_models() {
}
}
void server_models::load_startup_models() {
std::vector<std::string> to_load;
{
std::lock_guard<std::mutex> lk(mutex);
to_load = std::move(startup_models);
startup_models.clear();
}
for (const auto & name : to_load) {
SRV_INF("(startup) loading model %s\n", name.c_str());
load(name);
}
}
void server_models::update_meta(const std::string & name, const server_model_meta & meta) {
std::lock_guard<std::mutex> lk(mutex);
auto it = mapping.find(name);