Add REST route for platform config

Fixes #566
This commit is contained in:
Girish Ramakrishnan
2018-07-25 13:06:38 -07:00
parent f4d7d4e7f2
commit 0cb03e3789
4 changed files with 63 additions and 24 deletions

View File

@@ -390,6 +390,11 @@ function getPlatformConfig(callback) {
function setPlatformConfig(platformConfig, callback) {
assert.strictEqual(typeof callback, 'function');
for (let addon of [ 'mysql', 'postgresql', 'mail', 'mongodb' ]) {
if (!platformConfig[addon]) continue;
if (platformConfig[addon].memorySwap < platformConfig[addon].memory) return callback(new SettingsError(SettingsError.BAD_FIELD, 'memorySwap must be larger than memory'));
}
settingsdb.set(exports.PLATFORM_CONFIG_KEY, JSON.stringify(platformConfig), function (error) {
if (error) return callback(new SettingsError(SettingsError.INTERNAL_ERROR, error));