Rework the oom notification

This commit is contained in:
Johannes Zellner
2019-01-08 14:20:08 +01:00
parent 07e052b865
commit 85ea9b3255
2 changed files with 12 additions and 9 deletions
+3 -5
View File
@@ -133,18 +133,16 @@ function processDockerEvents(intervalSecs, callback) {
stream.on('data', function (data) {
var ev = JSON.parse(data);
appdb.getByContainerId(ev.id, function (error, app) { // this can error for addons
var program = error || !app.appStoreId ? ev.id : app.appStoreId;
var context = JSON.stringify(ev);
var program = error || !app.id ? ev.id : `app-${app.id}`;
var now = Date.now();
if (app) context = context + '\n\n' + JSON.stringify(app, null, 4) + '\n';
const notifyUser = (!app || !app.debugMode) && (now - gLastOomMailTime > OOM_MAIL_LIMIT);
debug('OOM Context: %s. notifyUser: %s. lastOomTime: %s (now: %s)', context, notifyUser, gLastOomMailTime, now);
debug('OOM %s notifyUser: %s. lastOomTime: %s (now: %s)', program, notifyUser, gLastOomMailTime, now, ev);
// do not send mails for dev apps
if (notifyUser) {
notifications.oomEvent(program, context); // app can be null if it's an addon crash
notifications.oomEvent(program, { app: app || null, details: ev }); // app can be null if it's an addon crash
gLastOomMailTime = now;
}
});