Add a way to persist addon memory configuration

Fixes #555
This commit is contained in:
Girish Ramakrishnan
2018-05-16 14:00:55 -07:00
parent 81e29c7c2b
commit 052050f48b
2 changed files with 18 additions and 0 deletions
+17
View File
@@ -47,6 +47,7 @@ function start(callback) {
// short-circuit for the restart case
if (_.isEqual(infra, existingInfra)) {
debug('platform is uptodate at version %s', infra.version);
updateAddons();
emitPlatformReady();
return callback();
}
@@ -67,6 +68,7 @@ function start(callback) {
locker.unlock(locker.OP_PLATFORM_START);
updateAddons();
emitPlatformReady();
callback();
@@ -80,6 +82,21 @@ function stop(callback) {
taskmanager.pauseTasks(callback);
}
function updateAddons() {
var platformConfig = safe.JSON.parse(safe.fs.readFileSync(paths.PLATFORM_CONFIG_FILE, 'utf8'));
if (!platformConfig) platformConfig = { };
for (var containerName of [ 'mysql', 'postgresql', 'mail', 'mongodb' ]) {
const containerConfig = platformConfig[containerName];
if (!containerConfig) continue;
if (!containerConfig.memory || !containerConfig.memorySwap) continue;
const cmd = `docker update --memory ${containerConfig.memory} --memory-swap ${containerConfig.memorySwap} ${containerName}`;
shell.execSync(`update${containerName}`, cmd);
}
}
function emitPlatformReady() {
// give some time for the platform to "settle". For example, mysql might still be initing the
// database dir and we cannot call service scripts until that's done.