mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
fix: build step defaults to series instead of parallel
- The logic for the build step now defaults to series instead of parallel, unless more than 4 CPU cores are detected by the os library. - The `--series` flag still exists, and will enforce build in series, as before.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const os = require('os');
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const winston = require('winston');
|
const winston = require('winston');
|
||||||
const nconf = require('nconf');
|
const nconf = require('nconf');
|
||||||
@@ -150,7 +151,14 @@ exports.build = function (targets, options, callback) {
|
|||||||
targets = targets.split(',');
|
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
|
targets = targets
|
||||||
// get full target name
|
// get full target name
|
||||||
@@ -195,14 +203,14 @@ exports.build = function (targets, options, callback) {
|
|||||||
require('./minifier').maxThreads = threads - 1;
|
require('./minifier').maxThreads = threads - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parallel) {
|
if (series) {
|
||||||
winston.info('[build] Building in parallel mode');
|
winston.info('[build] Building in parallel mode');
|
||||||
} else {
|
} else {
|
||||||
winston.info('[build] Building in series mode');
|
winston.info('[build] Building in series mode');
|
||||||
}
|
}
|
||||||
|
|
||||||
startTime = Date.now();
|
startTime = Date.now();
|
||||||
buildTargets(targets, parallel, next);
|
buildTargets(targets, !series, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
totalTime = (Date.now() - startTime) / 1000;
|
totalTime = (Date.now() - startTime) / 1000;
|
||||||
|
|||||||
Reference in New Issue
Block a user