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
.
我想定期记录我的Java应用程序的jmap直方图,这个Heroku Dev页面描述了如何通过使用with_jmap前缀java命令来获取Heroku Java应用程序的jmap histos。
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.
但是,如果我使用shell脚本启动我的Java应用程序并且我不想修改该shell脚本该怎么办?我没有看到相同的文档。
2 个解决方案
#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
如果您知道如何查找底层Java进程的PID,则可以创建自己的with_jmap脚本并将其添加到项目中。该脚本的源代码如下: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.
除了一些ps之外,我不确定是否有一个好方法可以做到这一点... | grep ...命令。
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:
基于此讨论,已改进了with_jmap命令以支持shell脚本。所以你应该能够这样设置你的Procfile:
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.
并将sh start.sh替换为您的脚本,Java命令或启动Java进程的任何其他命令。
#2
Heroku recently released ps:exec in beta. Have a look at https://devcenter.heroku.com/articles/heroku-exec#using-java-debugging-tools
Heroku最近发布了ps:exec beta版。看看https://devcenter.heroku.com/articles/heroku-exec#using-java-debugging-tools
#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
如果您知道如何查找底层Java进程的PID,则可以创建自己的with_jmap脚本并将其添加到项目中。该脚本的源代码如下: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.
除了一些ps之外,我不确定是否有一个好方法可以做到这一点... | grep ...命令。
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:
基于此讨论,已改进了with_jmap命令以支持shell脚本。所以你应该能够这样设置你的Procfile:
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.
并将sh start.sh替换为您的脚本,Java命令或启动Java进程的任何其他命令。
#2
Heroku recently released ps:exec in beta. Have a look at https://devcenter.heroku.com/articles/heroku-exec#using-java-debugging-tools
Heroku最近发布了ps:exec beta版。看看https://devcenter.heroku.com/articles/heroku-exec#using-java-debugging-tools