0

What we are already doing is that JVM can respawn itself from the last own shutdown hook running. It strongly depends on proper closing of all resources and ports. And here comes the problem - all ports are open/closed by the application, except the debug port. That is open with the start of the JVM, and closed with its death.

Is it possible to open/close the debug port somehow from the inside of the application, not just using command line options?

1 Answer 1

1

You cannot control the JVM process from your Java application running inside the JVM.
JDWP Debug Agent is a tool provided by the JVM and runs at a lower level than your application.

Shutdown hooks run before the JVM tears down subsystems, and the debug agent is destroyed after the shutdown hook

I would advise against using the shutdown hooks to provide resilience, as it can lead to restart loops.

Instead, you can offload the recovery to an external supervisor. In this example, a cron job is used. Or you can run the Java application from a parent process (eg, bash script) that will restart it if it crashes.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.