简体   繁体   English

来自child_process和主要master的Node.js分支

[英]Nodejs fork from child_process and main master

I have 3 files: - master.js - children_1.js - children_1_1.js 我有3个文件:-master.js-children_1.js-children_1_1.js

master.js contain: master.js包含:

var fork = require('child_process').fork;
var children_1 = fork('children_1.js');

children_1.js contain: children_1.js包含:

var fork = require('child_process').fork;
var children_1_1 = fork('children_1_1.js');

children_1_1.js: children_1_1.js:

process.send({hello: 'world'});

But this message come into children_1.js. 但是此消息进入children_1.js。 How can i send message from children_1_1.js to master.js? 我如何从children_1_1.js向master.js发送消息? Is it possible in node.js standart complectation? 在node.js标准配置中有可能吗?

you have to forward this message in children_1.js when you fork, you create a new process, and node.js establisch an ipc channel between the forking and the forked process. 您必须在进行分叉,创建新进程并在分叉与分叉进程之间建立ipc通道的ipc通道时,在children_1.js中转发此消息。 nothing more 而已

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM