简体   繁体   English

如何使用 pm2 运行 2 个具有不同节点版本的应用程序

[英]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.我有 7 个微服务在节点上运行,少数在 python 和 go 上。 2 of the microservice have multiple instances (ie running in cluster mode). 2 的微服务有多个实例(即以集群模式运行)。

All microservices are managed by PM2.所有微服务都由 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.无论我在互联网上看到什么,它都说我只能在 fork 模式下使用 2 个版本。 How to run pm2 services on two different versions in cluster mode ?如何在集群模式下在两个不同版本上运行 pm2 服务

I do not want to use a load balancer or docker.我不想使用负载平衡器或 docker。

You can use nvm to manage your different node version you nedd, then for starting node apps, do that:您可以使用 nvm 来管理您需要的不同节点版本,然后要启动节点应用程序,请执行以下操作:

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

Naturaly, replace node nvm path according to your case.自然,根据您的情况替换节点 nvm 路径。

For installing nvm: https://github.com/nvm-sh/nvm#installing-and-updating用于安装 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

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

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