[英]Running 2nd non-web java app process in Heroku
I was wondering if it's possible to run a non-web java app in Heroku from within a web java app? 我想知道是否可以从Web Java应用程序中在Heroku中运行非Web Java应用程序? Basically I want to execute a command to run the non-web app jar:
基本上,我想执行一个命令来运行非Web应用程序jar:
Calling something like this in Heroku for one off process: 在Heroku中调用这样的事情进行一次处理:
Process proc = Runtime.getRuntime().exec("java -jar A.jar");
You probably don't want to execute the new process from the existing Java process. 您可能不想从现有的Java流程中执行新流程。 Instead, you should create a new process type in your app's
Procfile
, like this: 相反,您应该在应用程序的
Procfile
创建一个新的流程类型,如下所示:
web: java -jar webapp-runner.jar yourapp.war
worker: java -jar A.jar
Then you can run the worker process from the CLI heroku run worker
, or you can make an HTTP call to the Heroku API . 然后,您可以从CLI
heroku run worker
运行worker进程,或者可以对Heroku API进行HTTP调用。
I assume you are using heroku war:deploy
, which means you probably don't have a Procfile
at this time. 我假设您正在使用
heroku war:deploy
,这意味着您目前可能没有Procfile
。 You may need to switch to heroku jar:deploy
and include webapp-runner in your app manually . 您可能需要切换到
heroku jar:deploy
并在应用程序中手动包含webapp-runner 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.