Merge pull request from Icinga/bugfix/exceptions-in-config-sync

Catch exceptions in the thread running HandleConfigUpdate
This commit is contained in:
Alexander Aleksandrovič Klimov 2020-10-14 10:58:23 +02:00 committed by GitHub
commit 354a854d7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -312,7 +312,16 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin::Ptr& origin, const D
return Empty;
}
std::thread([origin, params]() { HandleConfigUpdate(origin, params); }).detach();
std::thread([origin, params, listener]() {
try {
HandleConfigUpdate(origin, params);
} catch (const std::exception& ex) {
auto msg ("Exception during config sync: " + DiagnosticInformation(ex));
Log(LogCritical, "ApiListener") << msg;
listener->UpdateLastFailedZonesStageValidation(msg);
}
}).detach();
return Empty;
}