Skip to content

[4.x] Add shutdown handler to control shutdown sequence in a deterministic … #8684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

tomas-langer
Copy link
Member

@tomas-langer tomas-langer commented Apr 19, 2024

…way (instead of shutdown hooks in multiple components)

Resolves. #8685

Description

Currently we add shutdown hooks when needed. Shutdown hooks are threads that are started in a non-deterministic order by the JVM when the process is about to exit.

This PR introduces a service HelidonShutdownHandler than can be either provided through ServiceLoader, or registered manually on io.helidon.Main and that honors Weight.

A single shutdown hook is introduced that invokes all the shutdown handlers in weighted order (higher weight first).

The Main also adds the required java.util.logging "hack" to keep logging active until the VM shuts down (does not work, and did not work in native image). Once the issue is fixed in Java, we can remove this "hack".

Replaced existing workaround and shutdown hook in LoomServer and HelidonContainerImpl.

This is a preparation for Helidon Service Registry/Inject.

…way (instead of shutdown hooks in multiple components)
@tomas-langer tomas-langer added the 4.x Version 4.x label Apr 19, 2024
@tomas-langer tomas-langer self-assigned this Apr 19, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Apr 19, 2024
@tomas-langer tomas-langer linked an issue Apr 19, 2024 that may be closed by this pull request
@tomas-langer tomas-langer merged commit 993cdcc into helidon-io:main Apr 22, 2024
@tomas-langer tomas-langer deleted the shutdown-handler branch April 22, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[4.x] Managed shutdown of JVM
2 participants