简体   繁体   中英

Running node.js pm2 remotely using pdsh

I have 4 servers running node.js with the help of pm2 (pm2 start app.js). I would like to restart pm2 on all 4 servers from another server using pdsh however when I run:

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. It appears that pdsh can't load nvm

If you've installed it from nvm it should be something like that:

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

Pm2 on the other hand should be in the node_modules directory:

~/.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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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