Skip to content

Node.js based forum software built for the modern web

fix: build step defaults to series instead of parallel

Julian Lam3fac09b1ab1c
diff --git a/src/meta/build.js b/src/meta/build.js
index 0a99bd5837..11d4cec921 100644
--- a/src/meta/build.js
+++ b/src/meta/build.js
@@ -1,5 +1,6 @@
'use strict';
+const os = require('os');
const async = require('async');
const winston = require('winston');
const nconf = require('nconf');
@@ -150,7 +151,14 @@ exports.build = function (targets, options, callback) {
targets = targets.split(',');
}
- var parallel = !nconf.get('series') && !options.series;
+ let series = nconf.get('series') || options.series;
+ if (series === undefined) {
+ // Detect # of CPUs and select strategy as appropriate
+ winston.verbose('[build] Querying CPU core count for build strategy');
+ const cpus = os.cpus();
+ series = cpus.length < 4;
+ winston.verbose('[build] System returned ' + cpus.length + ' cores, opting for ' + (series ? 'series' : 'parallel') + ' build strategy');
+ }
targets = targets
// get full target name
@@ -195,14 +203,14 @@ exports.build = function (targets, options, callback) {
require('./minifier').maxThreads = threads - 1;
}
- if (parallel) {
+ if (series) {
winston.info('[build] Building in parallel mode');
} else {
winston.info('[build] Building in series mode');
}
startTime = Date.now();
- buildTargets(targets, parallel, next);
+ buildTargets(targets, !series, next);
},
function (next) {
totalTime = (Date.now() - startTime) / 1000;