Send emails for apptask crash

This commit is contained in:
Johannes Zellner
2019-01-19 13:30:24 +01:00
parent bdcd9e035c
commit d3331fea7f
2 changed files with 23 additions and 1 deletions
+21 -1
View File
@@ -14,7 +14,8 @@ exports = module.exports = {
adminChanged: adminChanged,
oomEvent: oomEvent,
appDied: appDied,
unexpectedExit: unexpectedExit
unexpectedExit: unexpectedExit,
apptaskCrash: apptaskCrash
};
var assert = require('assert'),
@@ -226,3 +227,22 @@ function unexpectedExit(eventId, processName, crashLogFile) {
if (error) console.error(error);
});
}
function apptaskCrash(eventId, appId, crashLogFile) {
assert.strictEqual(typeof eventId, 'string');
assert.strictEqual(typeof appId, 'string');
assert.strictEqual(typeof crashLogFile, 'string');
var subject = `Apptask for ${appId} crashed`;
var crashLogs = safe.fs.readFileSync(crashLogFile, 'utf8');
// also send us a notification mail
if (config.provider() === 'caas') mailer.unexpectedExit('support@cloudron.io', subject, crashLogs);
actionForAllAdmins([], function (admin, callback) {
mailer.unexpectedExit(admin.email, subject, crashLogs);
add(admin.id, eventId, subject, 'Detailed logs have been sent to your email address.', '/#/system', callback);
}, function (error) {
if (error) console.error(error);
});
}