add apps.getMemoryLimit

This commit is contained in:
Girish Ramakrishnan
2021-01-20 12:12:14 -08:00
parent a14dbbe77a
commit 4d482d11ee
2 changed files with 17 additions and 8 deletions

View File

@@ -34,6 +34,7 @@ exports = module.exports = {
};
var addons = require('./addons.js'),
apps = require('./apps.js'),
async = require('async'),
assert = require('assert'),
BoxError = require('./boxerror.js'),
@@ -268,14 +269,7 @@ function createSubcontainer(app, name, cmd, options, callback) {
let appEnv = [];
Object.keys(app.env).forEach(function (name) { appEnv.push(`${name}=${app.env[name]}`); });
// first check db record, then manifest
var memoryLimit = app.memoryLimit || manifest.memoryLimit || 0;
if (memoryLimit === -1) { // unrestricted
memoryLimit = 0;
} else if (memoryLimit === 0 || memoryLimit < constants.DEFAULT_MEMORY_LIMIT) { // ensure we never go below minimum (in case we change the default)
memoryLimit = constants.DEFAULT_MEMORY_LIMIT;
}
let memoryLimit = apps.getMemoryLimit(app);
// give scheduler tasks twice the memory limit since background jobs take more memory
// if required, we can make this a manifest and runtime argument later