如何在群集模式下使用pm2启动node.js应用程序? [英] How to start node.js app with pm2 in cluster mode?

查看:92
本文介绍了如何在群集模式下使用pm2启动node.js应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试使用octa核心处理器在ubuntu 14.04上以pm2 0.12.8启动我们的应用程序. git hub上的read me有一个非常简单的命令,可以在集群模式下运行节点应用程序.

We are trying to start our app with pm2 0.12.8 on ubuntu 14.04 with octa core proccessor. The read me on the git hub has a very straight forward command for running node app in cluster mode.

#群集模式

$ pm2 start app.js -i 0        **# Will start maximum processes with LB depending on available CPUs**
$ pm2 start app.js -i max      **# Same as above, but deprecated yet.**

但是上述命令对我们不起作用.当我们尝试运行这些命令时,pm2仅列出一个实例.

But the above command are not working for us. When we try to run these commands only one instance is listed by pm2.

为什么? 任何建议

谢谢

推荐答案

您是否尝试过启动固定数量的进程?即

have you tried starting a fixed number of processes? i.e.

pm2 start app.js -i 2 //should start two instances.

"pm2 monit"向您显示什么?

what does "pm2 monit" show you?

也尝试

pm2 stop all
pm2 delete all 

然后

pm2 start app.js -i 0

如果您在pm2中停止一个进程,即使该进程未运行,它仍会为其保留一个cpu.您应该始终使用pm2 delete

if you stop a process in pm2 it still reserves one cpu for it even if its not running. you should allways use pm2 delete

这篇关于如何在群集模式下使用pm2启动node.js应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆