简体   繁体   中英

Install4j: Is is possible to configure an install4j launcher to respond to kill -3 and generate a thread dump?

I would like to automatically create a thread dump as part of a log collection script I have written.

I know that it is possible to generate a thread dump using jstack or kill -3 . The customer running the log collection script will only have a JRE installed so jstack is not an option.

If I use jstack and the pid of the JVM that the install4j launcher creates I get the thread dump...however invoking kill -3 with the same pid generates no output. I am currently directing both stderror and stdout to files using the install4j launcher configuration.

This is a linux launcher that is configured with the service option.

FWIW...I have tried not directing the output and also running my application as a console program instead of a service and none of these allow 'kill -3' to work.

I'm using install4j 6.0

Lastly, I do not want to use -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=dump.log because of the unknown overhead it might create.

Any help would be appreciated!

I would suggest to use the ThreadMXBean to get this information programmatically in the same process rather than use signal handlers from another process. The API documentation is at

http://docs.oracle.com/javase/8/docs/api/java/lang/management/ThreadMXBean.html

Here's a full example of how to use this MBean.

In that way you can write the information explicitly to wherever you want it to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM