如何生成多个工作者并将其绑定到Heroku上的非Web Java应用程序 [英] How to generate multi workers and bind them to non-web Java applications on Heroku

查看:107
本文介绍了如何生成多个工作者并将其绑定到Heroku上的非Web Java应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过本教程在Heroku服务器上生成两名工作人员。

但是基于这个例子,我只有一个工人同时运行。是否有可能在应用程序启动时生成2个运行2个差异作业的工作人员?



我已经尝试通过使用以下命令来缩放工作人员: heroku ps :scale worker = 2 。但是,当我这样做时,它只会影响到WorkerProcess类,并且我有两个WorkerProcess类同时运行。

解决方案

你可以拥有尽可能多的工作进程。他们只需要在你的Procfile中有不同的名字。在你引用的文章中,单个worker被称为 worker ,但你的Procfile可以用两个不同的工作者称为 updater mailer

  web:java -jar web -app.jar $ PORT 
updater:sh worker / target / bin / updater
mailer:sh worker / target / bin / mailer

如果您使用的是文章中显示的 appassembler-maven-plugin ,那么您还需要添加另一个< program> ...< / program> 元素,以便生成底层启动脚本。


I tried this tutorial to generate two workers on Heroku Server.

But based on this example I just have one worker run at the same time. Is it possible to generate 2 workers that run 2 difference jobs when the application starts?

I already tried to scale the workers by using:heroku ps:scale worker=2. But when I do this it only affects to WorkerProcess class and I have two WorkerProcess classes running at the same time.

解决方案

Yes, you can have as many worker processes as you'd like. They just need to have different names in your Procfile. In the article you cited, the single worker is just called worker, but your Procfile could look something like this with two different workers called updater and mailer:

web: java -jar web-app.jar $PORT
updater: sh worker/target/bin/updater
mailer: sh worker/target/bin/mailer

If you're using the appassembler-maven-plugin shown in the article, you'll also need to add another <program>...</program> element for each of your workers so the nessisary start scripts are generated.

这篇关于如何生成多个工作者并将其绑定到Heroku上的非Web Java应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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