detect oom in tasks correctly

This commit is contained in:
Girish Ramakrishnan
2022-11-02 22:39:25 +01:00
parent 80a3ca0f46
commit 8bc3b832e7
2 changed files with 9 additions and 8 deletions
+3 -4
View File
@@ -171,9 +171,8 @@ function startTask(id, options, callback) {
if (!gTasks[id]) return; // ignore task exit since we are shutting down. see stopAllTasks
const code = sudoError ? sudoError.code : 0;
const signal = sudoError ? sudoError.signal : 0;
debug(`startTask: ${id} completed with code ${code} and signal ${signal}`);
debug(`startTask: ${id} completed with code ${code}`);
if (options.timeout) clearTimeout(killTimerId);
@@ -186,9 +185,9 @@ function startTask(id, options, callback) {
message: `Task ${id} ${timedOut ? 'timed out' : 'stopped'}` ,
code: timedOut ? exports.ETIMEOUT : exports.ESTOPPED
};
} else { // task crashed
} else { // task crashed. for code, maybe we can check systemctl show box-task-1707 -p ExecMainStatus
taskError = {
message: signal === 9 ? `Task ${id} crashed as it ran out of memory` : `Task ${id} crashed with code ${code} and signal ${signal}`,
message: code === 2 ? `Task ${id} crashed as it ran out of memory` : `Task ${id} crashed with code ${code}`,
code: exports.ECRASHED
};
}