简体   繁体   English

在node.js集群中提供静态文件?

[英]Serving static files in a node.js cluster?

Let's say I have a cluster environment where I basically have the main process (the master) and then I have another 8 worker processes (my cluster). 假设我有一个集群环境,在这里我基本上拥有主进程(主服务器),然后又有8个辅助进程(我的集群)。 Should the static files be hosted by the main process or should they be hosted on the cluster processes? 静态文件应该由主进程托管还是应在群集进程上托管?

If you're using the Node.js built-in Cluster module , the main process should not start an HTTP server, as it will not be able to listen on the same port as the workers. 如果您正在使用Node.js内置的Cluster模块 ,则主进程不应启动HTTP服务器,因为它将无法在worker所在的端口上进行侦听。 Static files, as with everything else, should be hosted by the workers. 静态文件以及其他所有文件都应由工作人员托管。

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

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