diff --git a/dashboard/src/views/services.html b/dashboard/src/views/services.html index c3d0ff931..2c8b33d74 100644 --- a/dashboard/src/views/services.html +++ b/dashboard/src/views/services.html @@ -12,7 +12,7 @@
diff --git a/dashboard/src/views/services.js b/dashboard/src/views/services.js index 4a2bea5bd..4383efad6 100644 --- a/dashboard/src/views/services.js +++ b/dashboard/src/views/services.js @@ -20,12 +20,13 @@ angular.module('Application').controller('ServicesController', ['$scope', '$loca if (error) return console.log('Error getting status of ' + serviceName + ':' + error.message); var service = $scope.services.find(function (s) { return s.name === serviceName; }); - if (!service) $scope.services[serviceName] = service; + if (!service) callback(new Error('no such service' + serviceName)); // cannot happen service.status = result.status; service.config = result.config; service.memoryUsed = result.memoryUsed; service.memoryPercent = result.memoryPercent; + service.defaultMemoryLimit = result.defaultMemoryLimit; callback(null, service); }); @@ -83,7 +84,7 @@ angular.module('Application').controller('ServicesController', ['$scope', '$loca $scope.serviceConfigure.memoryTicks = []; // we max system memory and current service memory for the case where the user configured the service on another server with more resources var nearest256m = Math.ceil(Math.max($scope.memory.memory, service.config.memoryLimit) / (256*1024*1024)) * 256 * 1024 * 1024; - var startTick = 256 * 1024 * 1024; + var startTick = service.defaultMemoryLimit; for (var i = startTick; i <= nearest256m; i *= 2) { $scope.serviceConfigure.memoryTicks.push(i); @@ -125,7 +126,7 @@ angular.module('Application').controller('ServicesController', ['$scope', '$loca }, resetToDefaults: function () { - $scope.serviceConfigure.memoryLimit = 256 * 1024 * 1024; // 256MB default + $scope.serviceConfigure.memoryLimit = $scope.serviceConfigure.service.defaultMemoryLimit; }, reset: function () { diff --git a/src/services.js b/src/services.js index 09a46781f..388dd9c9d 100644 --- a/src/services.js +++ b/src/services.js @@ -383,7 +383,7 @@ async function getServiceStatus(id) { throw new BoxError(BoxError.NOT_FOUND, 'Service not found'); } - const tmp = { + const result = { name: name, status: null, memoryUsed: 0, @@ -393,20 +393,21 @@ async function getServiceStatus(id) { config: {} }; - const result = await containerStatusFunc(); - tmp.status = result.status; - tmp.memoryUsed = result.memoryUsed; - tmp.memoryPercent = result.memoryPercent; - tmp.error = result.error || null; - tmp.healthcheck = result.healthcheck || null; + const status = await containerStatusFunc(); + result.status = status.status; + result.memoryUsed = status.memoryUsed; + result.memoryPercent = status.memoryPercent; + result.defaultMemoryLimit = service.defaultMemoryLimit; + result.error = status.error || null; + result.healthcheck = status.healthcheck || null; - tmp.config = await getServiceConfig(id); + result.config = await getServiceConfig(id); - if (!tmp.config.memoryLimit && service.defaultMemoryLimit) { - tmp.config.memoryLimit = service.defaultMemoryLimit; + if (!result.config.memoryLimit && service.defaultMemoryLimit) { + result.config.memoryLimit = service.defaultMemoryLimit; } - return tmp; + return result; } async function configureService(id, data, auditSource) {