Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku run Jar file once deployed?

I have deployed my jar file to heroku using:

heroku deploy:jar <filename>.jar --app <appname>

Once deployed, how do I run the jar file with specific params, i.e. locally i would execute:

java -jar <filename>.jar <param1> <param2>

Am i using the Heroku service correctly? In essence I just need to run the Main command within the jar file and get the logs when completed.

Any help would be much appreciated.

like image 735
Joss MT Avatar asked Nov 07 '22 08:11

Joss MT


1 Answers

heroku deploy:jar <filename>.jar --app <appname>

With this you essentially hardcorded:

jar <filename>.jar

Here is an example where you can configure parameters for your command

https://github.com/NNTin/shell-kun/tree/6b35e4b731bcf500366f60bbceafe076bf969fe1

Note: We are looking here at older software because HEAD no longer has it.

You need Procfile. app.json and the Heroku Deploy (see link in README.md) button are optional. They make deploying easier since you don't have to touch terminal/CLI.

Essentially you extend your Procfile to:

web: jar <filename>.jar $ARGS_AND_FLAGS
worker: jar <filename>.jar $ARGS_AND_FLAGS

web when you are utilizing a $PORT, worker when not.

Now you can modify your command by editing the environment variable ARGS_AND_FLAGS.

enter image description here

In this case the web process is activated and the worker process is deactivated.

enter image description here

After you changed your environment variable you can deactivate and then activate your process.

like image 111
Tin Nguyen Avatar answered Nov 25 '22 11:11

Tin Nguyen