pm2和pm2-runtime有什么区别? [英] What's the difference between pm2 and pm2-runtime?

查看:1577
本文介绍了pm2和pm2-runtime有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在将一些已经在同一台机器上执行的项目转移到各个泊坞窗.我尝试在其中一个docker项目上使用pm2以确保如果出现问题(该项目是易失性项目),服务将重新启动,并且某些示例要求Dockerfile使用pm2-runtime而不是pm2 .我一直在寻找这两者之间的差异,但找不到特定的东西,有人可以帮忙吗?

I've been transferring some projects that have been executing on the same machine to individual dockers each. I've tried to use pm2 on one of these docker projects to make sure the service would restart if something go wrong (it's a volatile project) and some of the examples demands the Dockerfile to use pm2-runtime instead of pm2. I've been searching for the differences of these two but I couldn't find something specific, could someone help?

推荐答案

pm2和pm2-runtime之间的主要区别是

The main difference between pm2 and pm2-runtime is

  • pm2-runtime是为Docker容器设计的,它将应用程序置于前台,从而使容器保持运行状态,
  • pm2专为在后台发送或运行应用程序的正常使用而设计.

简单来说,容器的寿命就是CMDentrypoint的寿命.

In simple words, the life of the container is the life of CMD or entrypoint.

例如

Dockerfile

Dockerfile

FROM node:alpine
RUN npm install pm2 -g
COPY . /app
WORKDIR /app
CMD [ "pm2", "start","/app/server.js"]

在这种情况下,容器将在运行该进程后立即死亡.

In this case, the container will die as soon as it run the process.

要解决此问题,您需要 pm2-runtime

To deal with this, you have pm2-runtime

FROM node:alpine
RUN npm install pm2 -g
COPY . /app
WORKDIR /app
ENV NODE_ENV=development
CMD [ "pm2-runtime", "start","/app/bin/www"]

随着容器继续运行并分配tty会话.

As the container keeps running and it allocates tty session.

从文档中

pm2-runtime的目标是将您的应用程序包装为适当的 Node.js生产环境.解决跑步时的主要问题 像这样的容器内的Node.js应用程序:

The goal of pm2-runtime is to wrap your applications into a proper Node.js production environment. It solves major issues when running Node.js applications inside a container like:

用于高应用程序可靠性过程流的第二个过程回退 控制自动应用程序监视以使其始终保持理智和 高性能的自动源地图发现和解析支持 除此之外,使用PM2作为容器和容器之间的一层 应用程序带来PM2强大的功能,例如应用程序声明 文件,可自定义的日志系统以及其他出色的功能来管理您的 生产环境中的Node.js应用程序.

Second Process Fallback for High Application Reliability Process Flow Control Automatic Application Monitoring to keep it always sane and high performing Automatic Source Map Discovery and Resolving Support Further than that, using PM2 as a layer between the container and the application brings PM2 powerful features like application declaration file, customizable log system and other great features to manage your Node.js application in production environment.

docker-pm2-nodejs

这篇关于pm2和pm2-runtime有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆