From 5aec919a4e03613b59132dfcf0d2838d2d961723 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Sun, 19 Feb 2017 15:06:49 -0800 Subject: [PATCH] Worker count defaults to CPU core count --- lib/cluster.js | 3 +++ lib/config.coffee | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/cluster.js b/lib/cluster.js index c416f8f..23efb2b 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -117,6 +117,9 @@ function start(service) { let workerCount = config.get(`${service.toUpperCase()}_WORKER_PROCESSES`); + if (!workerCount) + workerCount = Math.max(2, require("os").cpus().length); + for (let i = 0; i < workerCount; ++ i) cluster.fork(); } diff --git a/lib/config.coffee b/lib/config.coffee index a3e9a57..3a132f3 100644 --- a/lib/config.coffee +++ b/lib/config.coffee @@ -25,21 +25,21 @@ options = { REDIS_HOST : {type : 'string', default : '127.0.0.1'}, REDIS_DB : {type : 'int', default : 0}, - CWMP_WORKER_PROCESSES : {type : 'int', default : 4}, + CWMP_WORKER_PROCESSES : {type : 'int', default : 0}, CWMP_PORT : {type : 'int', default : 7547}, CWMP_INTERFACE : {type : 'string', default : '0.0.0.0'}, CWMP_SSL : {type : 'bool', default : false}, CWMP_LOG_FILE : {type: 'path', default : ''}, CWMP_ACCESS_LOG_FILE : {type : 'path', default : ''}, - NBI_WORKER_PROCESSES : {type : 'int', default : 2}, + NBI_WORKER_PROCESSES : {type : 'int', default : 0}, NBI_PORT : {type : 'int', default : 7557}, NBI_INTERFACE : {type : 'string', default : '0.0.0.0'}, NBI_SSL : {type : 'bool', default : false}, NBI_LOG_FILE : {type: 'path', default : ''}, NBI_ACCESS_LOG_FILE : {type : 'path', default : ''}, - FS_WORKER_PROCESSES : {type : 'int', default : 2}, + FS_WORKER_PROCESSES : {type : 'int', default : 0}, FS_PORT : {type : 'int', default : 7567}, FS_INTERFACE : {type : 'string', default : '0.0.0.0'}, FS_SSL : {type : 'bool', default : false},