]> cat aescling's git repositories - mastodon.git/commitdiff
Fix streaming server worker count (#2082)
authorkuro5hin <rusty@kuro5hin.org>
Tue, 18 Apr 2017 13:58:22 +0000 (09:58 -0400)
committerEugen <eugen@zeonfederated.com>
Tue, 18 Apr 2017 13:58:22 +0000 (15:58 +0200)
* Make sure we start at least one streaming worker, even if there's only one CPU and we're in production mode.

* Oops, let's make sure we're counting cpus right too.

streaming/index.js

index 366a39a6a287281b8945d74e9ae07205acab56c4..5e25085c25f2080a2fcc47643afc3352a8614f08 100644 (file)
@@ -19,7 +19,7 @@ dotenv.config({
 if (cluster.isMaster) {
   // cluster master
 
-  const core = +process.env.STREAMING_CLUSTER_NUM || (env === 'development' ? 1 : os.cpus().length - 1)
+  const core = +process.env.STREAMING_CLUSTER_NUM || (env === 'development' ? 1 : (os.cpus().length > 1 ? os.cpus().length - 1 : 1))
   const fork = () => {
     const worker = cluster.fork();
     worker.on('exit', (code, signal) => {