How to generate multi workers and bind them to non-web Java applications on Heroku

走远了吗. 提交于 2019-12-13 06:01:43

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/15650117/how-to-generate-multi-workers-and-bind-them-to-non-web-java-applications-on-hero

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