单个 heroku 应用程序上的多个工作程序/网络进程 [英] multiple worker/web processes on a single heroku app

查看:26
本文介绍了单个 heroku 应用程序上的多个工作程序/网络进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法配置多个工作进程和/或网络进程以在单个 Heroku 应用程序容器中运行?还是必须将其分解为多个 Heroku 应用程序?

Is there some way to configure multiple worker and/or web processes to run in the single Heroku app container? Or does this have to be broken up into multiple Heroku apps?

例如:

worker: node capture.js
worker: node process.js
worker: node purge.js
web: node api.js
web: node web.js

推荐答案

所有进程必须有唯一的名称.另外,webworker 这两个名字是无关紧要的,也没有什么特殊的意义. 唯一有一个有意义的名字的进程是 web 过程,如 Heroku 文档中所述:

All processes must have unique names. Additionally, the names web and worker are insignificant and carry no special meaning. The only process that carries a significant name is the web process, as stated in the Heroku docs:

Web 进程类型是特殊的,因为它是唯一的进程类型将从 Heroku 的路由器接收 HTTP 流量.其他工艺类型可以任意命名.-- (https://devcenter.heroku.com/articles/procfile)

The web process type is special as it’s the only process type that will receive HTTP traffic from Heroku’s routers. Other process types can be named arbitrarily. -- (https://devcenter.heroku.com/articles/procfile)

所以你想要一个 Procfile 像这样:

So you want a Procfile like so:

capture: node capture.js
process: node process.js
purge: node purge.js
api: node api.js
web: node web.js

然后您可以分别扩展每个流程:

You can then scale each process separately:

$ heroku ps:scale purge=4

这篇关于单个 heroku 应用程序上的多个工作程序/网络进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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