在Procfile中开发多个工作者(开发环境vs Heroku) [英] starting multiple workers in Procfile (development environment vs Heroku)

查看:134
本文介绍了在Procfile中开发多个工作者(开发环境vs Heroku)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Procfile,其内容如下:

I have a simple Procfile that reads:

web: bundle exec rails server thin -p $PORT
worker: bundle exec rake jobs:work

在Heroku上,这将启动N个工作任务,其中N是无论我已经缩放它。

On Heroku, this will launch N worker tasks, where N is whatever I've scaled it to be.

在我的开发系统中,

On my development system,

$ foreman start

只会启动一个工作任务。如果我想启动三个工作者,我需要一个类似于以下内容的Procfile:

will only launch one worker task. If I want to launch three workers, I need a Procfile that looks like:

web: bundle exec rails server thin -p $PORT
worker: bundle exec rake jobs:work
worker: bundle exec rake jobs:work
worker: bundle exec rake jobs:work

这是一个有些迂腐的问题,但是如果我希望我的开发环境像我的Heroku环境那样工作,启动N个工作任务的最佳方式是什么?是批准的方法来创建(例如)Procfile_local并通过 foreman -f使用它Procfile_local

This is a somewhat pedantic question, but if I want my development environment to behave like my Heroku environment, what's the best way to launch N worker tasks? Is the approved way to create (e.g.) Procfile_local and use it via foreman -f Procfile_local?

推荐答案

阿。谁会想到有一个在线工头手册页? ;)

Ah. Who would have guessed that there's an online man page for foreman? ;)

foreman start --concurrency="web=0,worker=6"

好的技巧。不需要单独的Procfile。

Does the trick nicely. No need to have a separate Procfile.

这篇关于在Procfile中开发多个工作者(开发环境vs Heroku)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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