diff --git a/installer/systemd/box-setup.sh b/installer/systemd/box-setup.sh index d827e316a..e75680bb4 100755 --- a/installer/systemd/box-setup.sh +++ b/installer/systemd/box-setup.sh @@ -19,7 +19,7 @@ fi # all sizes are in mb readonly physical_memory=$(free -m | awk '/Mem:/ { print $2 }') -readonly swap_size="${physical_memory}" +readonly swap_size="${physical_memory}" # if you change this, fix enoughResourcesAvailable() in client.js readonly app_count=$((${physical_memory} / 200)) # estimated app count readonly disk_size_gb=$(fdisk -l ${disk_device} | grep "Disk ${disk_device}" | awk '{ print $3 }') readonly disk_size=$((disk_size_gb * 1024)) diff --git a/src/constants.js b/src/constants.js index 6b68a9bfd..ad061df02 100644 --- a/src/constants.js +++ b/src/constants.js @@ -9,6 +9,6 @@ exports = module.exports = { ADMIN_CLIENT_ID: 'webadmin', // oauth client id ADMIN_APPID: 'admin', // admin appid (settingsdb) - DEFAULT_MEMORY_LIMIT: (256 * 1024 * 1024) + DEFAULT_MEMORY_LIMIT: (256 * 1024 * 1024) // see also client.js }; diff --git a/webadmin/src/js/client.js b/webadmin/src/js/client.js index e34f4b366..e54401ab6 100644 --- a/webadmin/src/js/client.js +++ b/webadmin/src/js/client.js @@ -6,8 +6,8 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification', function ($http, md5, Notification) { var client = null; - // Keep this in sync with docs and docker.js - var DEFAULT_MEMORY_LIMIT = 1024 * 1024 * 200; + // Keep this in sync with docs and constants.js, docker.js + var DEFAULT_MEMORY_LIMIT = 1024 * 1024 * 256; function ClientError(statusCode, messageOrObject) { Error.call(this); @@ -762,10 +762,11 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification', }; Client.prototype.enoughResourcesAvailable = function (app) { - var needed = app.manifest.memoryLimit || DEFAULT_MEMORY_LIMIT; + var needed = app.manifest.memoryLimit || DEFAULT_MEMORY_LIMIT; // RAM+Swap var used = this.getInstalledApps().reduce(function (prev, cur) { return prev + (cur.manifest.memoryLimit || DEFAULT_MEMORY_LIMIT); }, 0); var roundedMemory = Math.round(this.getConfig().memory / (1024 * 1024 * 1024)) * 1024 * 1024 * 1024; // round to nearest GB - var available = (roundedMemory || 0) - used; + var totalMemory = roundedMemory * 1.2; // box-setup.sh creates equal amount of swap. 1.2 factor is arbitrary + var available = (totalMemory || 0) - used; return (available - needed) >= 0; };