mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-13 15:38:59 +00:00
chore(multi-core): allow "CORES" nconf var, so can just use one core (or
however many) cc @paglias
This commit is contained in:
parent
1a84d01933
commit
c14af0e855
2 changed files with 5 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"PORT":3000,
|
||||
"IP":"0.0.0.0",
|
||||
"CORES":1,
|
||||
"BASE_URL":"http://localhost",
|
||||
"FACEBOOK_KEY":"123456789012345",
|
||||
"FACEBOOK_SECRET":"aaaabbbbccccddddeeeeffff00001111",
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@ var isProd = nconf.get('NODE_ENV') === 'production';
|
|||
var isDev = nconf.get('NODE_ENV') === 'development';
|
||||
|
||||
if (cluster.isMaster && (isDev || isProd)) {
|
||||
// Fork workers.
|
||||
var cpus = require('os').cpus();
|
||||
_.times(nconf.get("HEROKU_PROD") ? (cpus.length-1 || 1) : (_.min([cpus.length,2])), cluster.fork);
|
||||
// Fork workers. If config.json has CORES=x, use that - otherwise, use all cpus-1 (production)
|
||||
var cpus = require('os').cpus(),
|
||||
cores = +nconf.get("CORES");
|
||||
_.times(cores || cpus.length-1, cluster.fork);
|
||||
|
||||
cluster.on('disconnect', function(worker, code, signal) {
|
||||
var w = cluster.fork(); // replace the dead worker
|
||||
|
|
|
|||
Loading…
Reference in a new issue