Update server.cpp

Catched exceptions in server load.
This commit is contained in:
Robert Sinclair 2024-05-30 17:09:15 +03:00 committed by GitHub
parent d5c05821f3
commit 0001ec37b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3028,13 +3028,26 @@ int main(int argc, char ** argv) {
log_data["api_key"] = "api_key: " + std::to_string(sparams.api_keys.size()) + " keys loaded";
}
// load the model
if (!ctx_server.load_model(params)) {
state.store(SERVER_STATE_ERROR);
return 1;
} else {
try {
// Attempt to load the model
if (!ctx_server.load_model(params)) {
LOG_ERROR("unable to load model", {{"error", "Load model failed"}});
state.store(SERVER_STATE_ERROR);
return 1;
}
// Initialize the server context if the model is loaded successfully
ctx_server.init();
state.store(SERVER_STATE_READY);
} catch (const std::exception &e) {
// Catch known standard exceptions
LOG_ERROR("unable to load model", {{"error", e.what()}});
exit(1);
} catch (...) {
// Catch all other exceptions
LOG_ERROR("unable to load model", {{"error", "Unknown Exception"}});
exit(1);
}
LOG_INFO("model loaded", {});