sails.js 多个子进程,它们是什么? Ubuntu

sails.js multiple child process, what are those? Ubuntu

通过 运行 永远航行或直接用 node app.js --prod 调用它,根据 htop 我有一个看起来像克隆的 4 个子进程。

如果我省略 --prod 参数,我会得到等量的 grunt 进程。 如您所见,它们都使用了相同数量的内存、不同的 PID 和不同的 TIME+ 读数。

我很确定 sails 它不是自动集群,是吗?这是一台单核机器(虚拟机),所以我不知道那些进程是什么,还是 htop 中的错误?

根据这个问题htop-showing-multiple-java-processes-with-different-pids?rq=1

htop 将线程显示为不同的进程,但节点不是单线程的吗?如果这些是线程,它们来自哪里?

您使用 htop 看到的线程是用户态线程(用户线程),但是当您 运行 您的应用程序处于集群模式(例如 4 个实例)时,它会成为内核线程。 more on user threads

当你隐藏用户空间线程时,你看到的是内核 thread.while 运行 集群模式下的应用程序,你将为那里的每个应用程序的内核线程创建一个 application.And 的多个内核线程有几个与之关联的用户空间线程。

(对于 htop,您可以通过 F2 隐藏用户空间线程并显示选项)

请查看屏幕截图以获取解释。

four instances of my app in cluster mode since number of cores==4

ps commands showing kernel threads only

htop showing kernel threads only

htop showing kernel threads along with userland threads

在上一个屏幕截图中,您看到了一些内核和用户空间的线程,但还有更多。 我的意思是对于每个内核线程都有一些与之关联的用户空间线程。