真正的问题是当我分配节点进程时,需要一个JS模块路径作为child_process.fork()函数的第一个参数,并且一旦分叉,子进程就不会从其父进程继承任何东西.在我的例子中,我想要一个与Linux中的fork()系统调用类似的函数,该函数克隆父进程,继承所有内容并从fork()的确切位置继续执行.这可以在Node平台上实现吗?
解决方法
https://github.com/joyent/node/issues/2334#issuecomment-3153822
We’re not (ever) going to support fork.
not portable to windows
difficult conceptually for users
entire heap will be quickly copied with a compacting VM; no benefits from copy-on-write
not necessary
difficult for us to do
This is a special case of the spawn() functionality for spawning Node processes. In addition to having all the methods in a normal ChildProcess instance,the returned object has a communication channel built-in. See child.send(message,[sendHandle]) for details.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。