-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Fix plugin loggers on shutdown #5592
Fix plugin loggers on shutdown #5592
Conversation
josemmo
commented
May 8, 2021
- Added stop signal listener to MinecraftServer
- Fixes Disable plugins when shutting down server using SIGTERM/SIGINT #5270
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: sun.misc.SignalHandler is Sun proprietary API and may be removed in a future release
Dunno if we want to rely on this...
that API has been around for a loooong time, I can't really see something getting rid of it on the basis that it's the only way to actually hook into these signals afaik, I can't see this getting stripped out any time soon |
I'm assuming that you've tested that this doesn't bork anything when ran with/without jline? |
The attempt to init signal handler should be wrapped in try-catch then, just in case. |
Spigot-Server-Patches/0723-Fix-plugin-loggers-on-server-shutdown.patch
Outdated
Show resolved
Hide resolved
Tested on Java 8 with With JLine enabled the stop signal handler doesn't get called as JLine intercepts the program input.
Just created a simple project with JDK 16 and "sun.misc.*" is still there. It is also available in the internal "jdk.internal.misc.*" package. In the wost case scenario this package can be exposed with
If hooking into internal APIs is an issue the other alternative is to hijack the app log manager and override the System.setProperty("java.util.logging.manager", CustomLogManager.class.getName());
public static class CustomLogManager extends LogManager {
// [...]
@Override
public void reset() {
// Ignore method call if still shutting down
// [...]
}
} |
If there's a warning about it, that seems reason enough to avoid it. In JDK 16 there is also Strongly Encapsulate JDK Internals by Default. Now is definitely not the time to regress back to depending on internals. |
Ok, I guess the consensus here is to avoid using signal handlers. |
Just pushed a new patch that uses the custom log manager approach instead of signal handlers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean! Nice!
Spigot-Server-Patches/0739-Fix-plugin-loggers-on-server-shutdown.patch
Outdated
Show resolved
Hide resolved
- Added stop signal listener to MinecraftServer > When system property "terminal.jline" is false and the server receives a SIGINT/SIGTERM plugin, non-root loggers did not work due to how shutdown hooks work.
- Removed patch for PaperMC#5270 that used signal handlers (4dd4295)
- Created custom log manager to ignore calls to CustomLogManager#reset() before server has shutdown > When system property "terminal.jline" is false and the server receives a SIGINT/SIGTERM plugin, non-root loggers did not work due to how shutdown hooks work. Fixes PaperMC#5270
- Renamed com.destroystokyo.paper.log.CustomLogManager to io.papermc.paper.log.CustomLogManager - Updated patch number
55ecb75
to
4dce522
Compare
Had to rebase due to a mistype... 🤦♂️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More of a question than a comment.
Spigot-Server-Patches/0755-Fix-plugin-loggers-on-server-shutdown.patch
Outdated
Show resolved
Hide resolved
- Used string literal when setting "java.util.logging.manager" property
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Spigot-Server-Patches/0755-Fix-plugin-loggers-on-server-shutdown.patch
Outdated
Show resolved
Hide resolved
Could this be looked at again? |