starting multiple workers in Procfile (development environment vs Heroku)

霸气de小男生 提交于 2020-01-13 03:03:39

问题


I have a simple Procfile that reads:

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

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

On my development system,

$ foreman start

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

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?


回答1:


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

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

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




回答2:


Latest Foreman has renamed the option to --formation.

So, it's:

foreman start --formation="web=1,worker=2"

Source



来源:https://stackoverflow.com/questions/11423307/starting-multiple-workers-in-procfile-development-environment-vs-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!