updater: set the backup memory limit

This commit is contained in:
Girish Ramakrishnan
2021-02-01 14:07:23 -08:00
parent 14b2fa55c3
commit bcd04715c0
2 changed files with 27 additions and 20 deletions
+16 -9
View File
@@ -23,6 +23,7 @@ var apps = require('./apps.js'),
paths = require('./paths.js'),
safe = require('safetydance'),
semver = require('semver'),
settings = require('./settings.js'),
shell = require('./shell.js'),
tasks = require('./tasks.js'),
updateChecker = require('./updatechecker.js');
@@ -219,21 +220,27 @@ function updateToLatest(options, auditSource, callback) {
error = locker.lock(locker.OP_BOX_UPDATE);
if (error) return callback(new BoxError(BoxError.BAD_STATE, `Cannot update now: ${error.message}`));
tasks.add(tasks.TASK_UPDATE, [ boxUpdateInfo, options ], function (error, taskId) {
settings.getBackupConfig(function (error, backupConfig) {
if (error) return callback(error);
eventlog.add(eventlog.ACTION_UPDATE, auditSource, { taskId, boxUpdateInfo });
const memoryLimit = 'memoryLimit' in backupConfig ? Math.max(backupConfig.memoryLimit/1024/1024, 400) : 400;
tasks.startTask(taskId, { timeout: 20 * 60 * 60 * 1000 /* 20 hours */ }, (error) => {
locker.unlock(locker.OP_BOX_UPDATE);
tasks.add(tasks.TASK_UPDATE, [ boxUpdateInfo, options ], function (error, taskId) {
if (error) return callback(error);
debug('Update failed with error', error);
eventlog.add(eventlog.ACTION_UPDATE, auditSource, { taskId, boxUpdateInfo });
const timedOut = error.code === tasks.ETIMEOUT;
eventlog.add(eventlog.ACTION_UPDATE_FINISH, auditSource, { taskId, errorMessage: error.message, timedOut });
tasks.startTask(taskId, { timeout: 20 * 60 * 60 * 1000 /* 20 hours */, nice: 15, memoryLimit }, (error) => {
locker.unlock(locker.OP_BOX_UPDATE);
debug('Update failed with error', error);
const timedOut = error.code === tasks.ETIMEOUT;
eventlog.add(eventlog.ACTION_UPDATE_FINISH, auditSource, { taskId, errorMessage: error.message, timedOut });
});
callback(null, taskId);
});
callback(null, taskId);
});
});
}