node.js 什么是Procfile?和 Web 和 Worker

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16128395/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 14:15:30  来源:igfitidea点击:

What is Procfile? and Web and Worker

node.jsmongodbherokuprocfile

提问by Maulik Suchak

Is it necessary to give 'worker' information in Procfile? If yes then what it is actually - couldn't find nice article regarding this. I hope you guys might have idea. I have already added web: node server/server.js detail in the Procfile. Any help would be appreciated!

是否有必要在 Procfile 中提供“工人”信息?如果是,那么它实际上是什么 - 找不到关于此的好文章。我希望你们能有想法。我已经在 Procfile 中添加了 web: node server/server.js 详细信息。任何帮助,将不胜感激!

回答by Michelle Tilley

Procfile is a mechanism for declaring what commands are run by your application's dynos on the Heroku platform.

Procfile 是一种机制,用于声明您的应用程序的 dynos 在 Heroku 平台上运行哪些命令。

From Process Types and the Procfile, which is a good introduction, but basically you use the Procfile to tell Heroku how to run various pieces of your app. The part to the left of the colon on each line is the process type; the part on the right is the command to run to start that process.

来自Process Types 和 Procfile,这是一个很好的介绍,但基本上您使用 Procfile 来告诉 Heroku 如何运行应用程序的各个部分。每行冒号左边的部分是进程类型;右侧的部分是运行以启动该进程的命令。

Process types can be anything, although webis special, as Heroku will route HTTP requests to processes started with the webname. Other processes, such as background workers, can be named anything, and you can use the Heroku toolbelt to start or stop those processes by referring to its name.

进程类型可以是任何东西,尽管web很特殊,因为 Heroku 会将 HTTP 请求路由到以web名称开头的进程。其他进程,例如后台工作人员,可以任意命名,您可以使用 Heroku 工具带通过引用其名称来启动或停止这些进程。

So, in short, workeris not necessary, unless you want to run some other process in the background by controlling process with the heroku pscommand.

因此,简而言之,worker没有必要,除非您想通过使用heroku ps命令控制进程在后台运行其他一些进程。

回答by Kevin Sylvestre

You would only need a 'worker' entry in your Procfileif you plan on using some sort of background job system (i.e. queuing long running tasks for later). Heroku has more information here:

Procfile如果您计划使用某种后台作业系统(即,将长时间运行的任务排队以备后用),则您只需要一个“工人”条目。Heroku 在此处提供更多信息:

https://devcenter.heroku.com/articles/procfile

https://devcenter.heroku.com/articles/procfile