updater: set the backup memory limit
This commit is contained in:
+16
-9
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user