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

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

* only allow is_first_load to populate it

* nits

* nits 2
This commit is contained in:
Xuan-Son Nguyen
2026-08-20 15:22:16 +02:00
committed by GitHub
parent 8a832e4bf3
commit 9855ad69d3
4 changed files with 55 additions and 36 deletions
+12
View File
@@ -424,6 +424,18 @@ int llama_server(common_params & params, int argc, char ** argv) {
ctx_http.stop();
};
try {
models_routes->models.load_startup_models();
} catch (const std::exception & e) {
SRV_ERR("failed to load models on startup: %s\n", e.what());
ctx_http.stop();
if (ctx_http.thread.joinable()) {
ctx_http.thread.join();
}
clean_up();
return 1;
}
} else {
// setup clean up function, to be called before exit
clean_up = [&ctx_http, &ctx_server, &mcp_mgr]() {