简体   繁体   English

使用pdsh远程运行node.js pm2

[英]Running node.js pm2 remotely using pdsh

I have 4 servers running node.js with the help of pm2 (pm2 start app.js). 我有4台在pm2的帮助下运行node.js的服务器(pm2启动app.js)。 I would like to restart pm2 on all 4 servers from another server using pdsh however when I run: 我想使用pdsh从另一台服务器重新启动所有4台服务器上的pm2,但是在运行时:

pdsh -a "/root/.nvm/v0.10.30/bin/pm2 restart 0"

it returns: 它返回:

/root/.nvm/v0.10.30/bin/pm2: line 4: exec: : not found

I have also done similar to bellow: 我也做了类似以下的事情:

pdsh -a "sh /etc/profile && sh ~/.bash_profile && /root/.nvm/v0.10.30/bin/pm2 restart 0"

and same error occurs. 并发生相同的错误。

Thanks 谢谢

Try to run pm2 directly from the node path. 尝试直接从node路径运行pm2。 It appears that pdsh can't load nvm 看来pdsh无法加载nvm

If you've installed it from nvm it should be something like that: 如果您是从nvm安装的,则应该是这样的:

~/.nvm/v0.10.30/bin/node

Pm2 on the other hand should be in the node_modules directory: 另一方面,Pm2应该位于node_modules目录中:

~/.nvm/v0.10.30/lib/node_modules/pm2/bin/pm2

So if we combine all this it becomes: 因此,如果我们将所有这些结合起来,它将变成:

/root/.nvm/v0.10.30/bin/node /root/.nvm/v0.10.30/lib/node_modules/pm2/bin/pm2 restart 0 

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

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