We will make the percent allocation dynamic depending on the system. When we have servers with a large amount of RAM but little swap, we seem to use a lot of swap because of 50% allocation strategy. In such systems, we run out of swap and thus have OOM errors even though there is a lot of RAM available!
29 lines
945 B
JavaScript
29 lines
945 B
JavaScript
'use strict';
|
|
|
|
const async = require('async');
|
|
|
|
exports.up = function(db, callback) {
|
|
db.all('SELECT * FROM apps', function (error, apps) {
|
|
if (error) return callback(error);
|
|
|
|
async.eachSeries(apps, function (app, iteratorDone) {
|
|
if (!app.servicesConfigJson) return iteratorDone();
|
|
|
|
let servicesConfig = JSON.parse(app.servicesConfigJson);
|
|
for (const serviceName of Object.keys(servicesConfig)) {
|
|
const service = servicesConfig[serviceName];
|
|
if (!service.memorySwap) continue;
|
|
service.memoryLimit = service.memorySwap;
|
|
delete service.memorySwap;
|
|
delete service.memory;
|
|
}
|
|
|
|
db.runSql('UPDATE apps SET servicesConfigJson=? WHERE id=?', [ JSON.stringify(servicesConfig), app.id ], iteratorDone);
|
|
}, callback);
|
|
});
|
|
};
|
|
|
|
exports.down = function(db, callback) {
|
|
callback();
|
|
};
|