@joystick.js/node-canary 0.0.0-canary.442 → 0.0.0-canary.443
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"cluster";import n from"os";const
|
|
1
|
+
import r from"cluster";import n from"os";const i=(t=null)=>{const c=n.cpus().length;if(r.isPrimary){for(let s=0;s<c;s++){const e=r.fork();e.joystick_process=s+1,e.on("message",o=>{process.send&&process.send(o)}),process.on("message",o=>{e.send(o)})}r.on("exit",s=>{console.warn(`Worker ${s.process.pid} died.`)})}else t()};var d=i;export{d as default};
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@ const start_node_as_cluster = (callback = null) => {
|
|
|
11
11
|
// NOTE: Intentionally track the worker index on its process so we can
|
|
12
12
|
// check for a primary in our code (e.g., when running cluster of an app that
|
|
13
13
|
// has code we only want to run on 1/X workers, not all workers).
|
|
14
|
-
worker.
|
|
14
|
+
worker.joystick_process = i + 1;
|
|
15
15
|
|
|
16
16
|
worker.on("message", (message) => {
|
|
17
17
|
if (process.send) {
|