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 (i.e. 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:
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:
UPDATE
If
--interpreter
is not usable with cluster mode, you can try this trick.Once this done, you should have a new pm2 binary using another node version. You'll be able to launch a node script with
pm2-node-xx start app.js
.You will have two pm2 daemon running, one per node version. You can reproduce this recipe for all node version you need.