为什么 Node 无法在 Windows 的 worker 中设置命名管道服务器?

Why can't Node set up a named pipe server in a worker in Windows?

我正在努力在我正在进行的项目中启用集群支持。这个问题直接来自集群模块上 Nodejs 文档中的声明:

from: https://nodejs.org/api/cluster.html#cluster_cluster

Please note that, on Windows, it is not yet possible to set up a named pipe server in a worker.

  1. 这到底是什么意思?
  2. 这意味着什么?

根据文档和我所做的其他研究,我不清楚此限制的实际实际后果。

进程可以公开命名管道作为与其他相关方通信的方式 - 即。 nginx 服务器可以公开一个命名管道,所有传入请求都将发送到该管道(只是一个想法 - 我不确定 nginx 是否可以做到这一点)。

从 Node.js 进程(虽然不是集群工作程序),您可以启动一个 http 服务器(或者甚至是一个普通的 TCP 服务器)来侦听发送到这个命名管道的消息:

http.createServer().listen('\.\pipe\nginx')

.listen() 方法签名的文档 are here,特别是这部分感兴趣:

Start a server listening for connections on a given handle that has already been bound to a port, a UNIX domain socket, or a Windows named pipe

但是,根据警告,由于我无法理解的原因,集群工作程序无法使用此功能

Here is a relevant commit in Node.js 这暗示了这个限制。您可以通过打开集群的 Markdown 文档找到它,查看 git blame 并进一步了解历史,直到您到达引入此注释的提交。

正常的进程间通信不受此限制的影响,因此集群在 Win32 上的工作方式与在 Unix 系统上的工作方式相同。

Note: Upon further thought, that nginx example is a bit misleading since a named pipe, to my understanding, cannot be used for stateful bidirectional communication. It's just one-way, ie. source->listener. But I do hope I conveyed the general idea behind the limitation.