diff --git a/app/app/project/modalServerToolsController.js b/app/app/project/modalServerToolsController.js index fc4c7c9e..88a742a9 100644 --- a/app/app/project/modalServerToolsController.js +++ b/app/app/project/modalServerToolsController.js @@ -48,6 +48,15 @@ export class ModalServerToolsController { } if (vm.Message.showDebug()) vm.$log.debug('Project dir: ', vm.$scope.projectDir); + vm.$scope.numCores = vm.OsServer.getNumberCores(); + vm.$scope.numWorkers = vm.Project.getNumberWorkers(); + + } + + setNumWorkers(numWkrs){ + // set this so OsServer can access it when starting local server + const vm = this; + vm.Project.setNumberWorkers(numWkrs); } getLocalServer() { diff --git a/app/app/project/osServerService.js b/app/app/project/osServerService.js index 921b46bf..ccbe0611 100644 --- a/app/app/project/osServerService.js +++ b/app/app/project/osServerService.js @@ -47,12 +47,12 @@ export class OsServer { vm.$translate = $translate; vm.toastr = toastr; - // set number of workers + // set number of workers from project. vm.numCores = os.cpus().length; - vm.numWorkers = 1; - if (vm.numCores) { - vm.numWorkers = vm.numCores == 1 ? 1 : (vm.numCores - 1); - } + vm.numWorkers = vm.Project.getNumberWorkers(); + // if (vm.numCores) { + // vm.numWorkers = vm.numCores == 1 ? 1 : (vm.numCores - 1); + // } vm.$log.info('Number of cores: ', vm.numCores); vm.$log.info('Number of workers set to: ', vm.numWorkers); @@ -84,6 +84,7 @@ export class OsServer { initializeServer() { const vm = this; vm.numberDPsToDisplay = vm.Project.getNumberDPsToDisplay(); + vm.numWorkers = vm.Project.getNumberWorkers(); vm.localServerURL = 'http://localhost:8080'; // default URL. will be reset when starting server vm.serverStatuses = {local: 'stopped', remote: 'stopped'}; // started, stopped, error? vm.analysisStatus = ''; // '', starting, started, in progress, queued, completed, error, canceled @@ -263,9 +264,9 @@ export class OsServer { } - getNumWorkers() { + getNumberCores() { const vm = this; - return vm.numWorkers; + return vm.numCores; } getSelectedServerURL() { @@ -535,6 +536,9 @@ export class OsServer { // See "https://github.com/NREL/OpenStudio-server/tree/dockerize-osw/server/spec/files/batch_datapoints" for test files const deferred = vm.$q.defer(); + // refetch numWorkers in case it has changed in serverTools modal + vm.numWorkers = vm.Project.getNumberWorkers(); + // run META CLI will return status code: 0 = success, 1 = failure // start local server needs path to oscli (vm.cliPath) if (vm.platform == 'win32') diff --git a/app/app/project/projectService.js b/app/app/project/projectService.js index 85fef27e..001e361f 100644 --- a/app/app/project/projectService.js +++ b/app/app/project/projectService.js @@ -103,6 +103,7 @@ export class Project { vm.reportType = null; vm.runType = vm.runTypes[0]; vm.samplingMethod = vm.samplingMethods[0]; + vm.numberWorkers = null; vm.rubyMD5 = null; vm.mongoMD5 = null; vm.openstudioServerMD5 = null; @@ -182,6 +183,7 @@ export class Project { vm.downloadOSM = true; vm.downloadZIP = true; vm.gemfile = false; + vm.numberWorkers = 1; vm.timeoutWorkflow = 28800; vm.timeoutUploadResults = 28800; vm.timeoutInitWorker = 28800; @@ -284,6 +286,7 @@ export class Project { vm.datapoints = vm.pat.datapoints ? vm.pat.datapoints : vm.datapoints; vm.remoteSettings = vm.pat.remoteSettings ? vm.pat.remoteSettings : vm.remoteSettings; vm.serverScripts = vm.pat.serverScripts ? vm.pat.serverScripts : vm.serverScripts; + vm.numberWorkers = vm.pat.numberWorkers ? vm.pat.numberWorkers : vm.numberWorkers; // filesToInclude // convert paths to platform-specific delimiters @@ -1562,6 +1565,7 @@ export class Project { vm.pat.openstudioServerMD5 = vm.openstudioServerMD5; vm.pat.openstudioCLIMD5 = vm.openstudioCLIMD5; vm.pat.openstudioMD5 = vm.openstudioMD5; + vm.pat.numberWorkers = vm.numberWorkers; // measures and options vm.pat.measures = vm.measures; @@ -1782,6 +1786,16 @@ export class Project { return vm.numberDPsToDisplay; } + getNumberWorkers() { + const vm = this; + return vm.numberWorkers; + } + + setNumberWorkers(num) { + const vm = this; + vm.numberWorkers = num; + } + getSeedDir() { const vm = this; return vm.seedDir; diff --git a/app/app/project/serverTools.html b/app/app/project/serverTools.html index 9bd43e0c..8a973158 100644 --- a/app/app/project/serverTools.html +++ b/app/app/project/serverTools.html @@ -3,6 +3,11 @@