我应该在(Docker)容器中使用forever/pm2吗? [英] Should I use forever/pm2 within a (Docker) container?

查看:166
本文介绍了我应该在(Docker)容器中使用forever/pm2吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在重构几个node.js服务.所有这些文件以前都是在虚拟服务器上以forever开头的,如果进程崩溃,它们只会重新启动.

I am refactoring a couple of node.js services. All of them used to start with forever on virtual servers, if the process crashed they just relaunch.

现在,转到容器化和无状态的应用程序结构,我认为该过程应该退出,并且应该在发生故障时重新启动容器.

Now, moving to containerised and state-less application structures, I think the process should exit and the container should be restarted on a failure.

那是正确的吗?有好处还是缺点?

Is that correct? Are there benefits or disadvantages?

推荐答案

我的想法是不使用容器内进程管理器(永远为pm2),而是通过--restart=always(或其中之一)使用docker restart策略该选项的其他口味).这与整个docker理念更加一致,并且应该与容器内过程监控非常相似,因为Docker容器开始运行非常快.

My take is do not use an in-container process supervisor (forever, pm2) and instead use docker restart policy via the --restart=always (or one of the other flavors of that option). This is more inline with the overall docker philosophy, and should operate very similarly to in-container process supervision since docker containers start running very quickly.

我所见过的运行容器内过程监督的最强有力的倡导者是 phusion baseimage-docker README 如果您要探讨有关此主题的其他立场.

The strongest advocate for running in-container process supervision I've seen is in the phusion baseimage-docker README if you want to explore the other position on this topic.

这篇关于我应该在(Docker)容器中使用forever/pm2吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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