0

I want to log my Java application's jmap histogram periodically and this Heroku Dev page describes how to get jmap histos for a Heroku Java app by prefixing java command with with_jmap.

However, what if I'm launching my Java app with a shell script and I don't want to modify that shell script? I don't see much documentation for the same.

Buchi
  • 1,322
  • 4
  • 14
  • 33

2 Answers2

1

You could create your own with_jmap script and add it to your project, if you know how to find the PID of the underlying Java process. The source for the script is here: https://github.com/heroku/heroku-buildpack-jvm-common/blob/master/opt/with_jmap

I'm not sure if there is a good way to do this other than some ps ... | grep ... command.

EDIT

Based on this discussion, the with_jmap command has been improved to support shell scripts. So you should be able to set your Procfile thusly:

web: with_jmap sh start.sh

And replace sh start.sh with your script, a Java command, or any other command that launches a Java process.

codefinger
  • 10,088
  • 7
  • 39
  • 51
  • This certainly helps but I thought Heroku should give more flexibility for this, specially because many people might use the launchers generated by Gradle/Maven to launch the Java app. – Buchi May 18 '15 at 19:57
  • @Buchi can you file a support ticket with Heroku asking this question http://help.heroku.com (i work there and it will be forwarded to me). I think this is a valid case, but it hasn't come up very often. And it's something i'd like to support, so a ticket would help move that along. Thanks. – codefinger May 19 '15 at 20:57
0

Heroku recently released ps:exec in beta. Have a look at https://devcenter.heroku.com/articles/heroku-exec#using-java-debugging-tools

Lisinge
  • 2,017
  • 2
  • 27
  • 44