简体   繁体   中英

How to run 2 application with different node version using pm2

I am following microservice architecture for my application.

I have 7 microservices few running on the node and a few are on python and go. 2 of the microservice have multiple instances (ie running in cluster mode).

All microservices are managed by PM2.

Now I am upgrading the node versions of services one by one. Whatever I looked on the internet it says I can use 2 versions only on fork mode. How to run pm2 services on two different versions in cluster mode ?

I do not want to use a load balancer or docker.

You can use nvm to manage your different node version you nedd, then for starting node apps, do that:

sudo pm2 start app.js --interpreter=/home/user/.nvm/v4.4.2/bin/node

Naturaly, replace node nvm path according to your case.

For installing nvm: https://github.com/nvm-sh/nvm#installing-and-updating

Once installed to install node versions:

// Install last 16.x
nvm install 16

// Spécific version
nvm install 16.14.2

// List installed 
nvm list

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