-
Notifications
You must be signed in to change notification settings - Fork 119
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: make sure Minestom services stop like Bukkit services #1338
fix: make sure Minestom services stop like Bukkit services #1338
Conversation
This change implements a class transformer for net.minestom.server.MinecraftServer to call System.exit when MinecraftServer.stopCleanly is called.
As of now, this solution also works on server implementations build on hollow-cube/minestom-ce. |
Can we maybe implement this as discussed here (https://discord.com/channels/713041279277203457/777861579659411466/1182967379488161872) |
I'm going to update my implementation to match what we discussed back then. |
This change implements a class transformer for net.minestom.server.ServerProcessImpl to call System.exit when ServerProcessImpl.stop is called. The changes also take care of correctly patching the opcode, if label nodes follow the last return statement.
@0utplay I have updated the PR but can't initiate the build required. Feel free to also add a review to the code, the changes are pretty minimal. |
Thats because there are conflicts in the Wrapper class. I can resolve them later. |
…ut-down-transformer # Conflicts: # wrapper-jvm/src/main/java/eu/cloudnetservice/wrapper/Wrapper.java
.../main/java/eu/cloudnetservice/wrapper/transform/minestom/MinestomStopCleanlyTransformer.java
Outdated
Show resolved
Hide resolved
.../main/java/eu/cloudnetservice/wrapper/transform/minestom/MinestomStopCleanlyTransformer.java
Outdated
Show resolved
Hide resolved
.../main/java/eu/cloudnetservice/wrapper/transform/minestom/MinestomStopCleanlyTransformer.java
Outdated
Show resolved
Hide resolved
This change improves the quality of the MinestomStopCleanlyTransformer by making it final and handling the unlikely case, that there is no return statement in the method to be patched.
Motivation
Minestom is a very lightweight framework for implementing specialized Minecraft servers.
Especially when the full implementation or behavior of vanilla Minecraft is not needed, Minestom offers a way to run services with very little resources.
One issue that arised in conjunction with CloudNet is that services implemented using Minestom would not properly stop. Minestom would shut down and the service would get unregistered from CloudNet but the processes would be kept running.
Modification
This pull request mimics the behavior of vanilla implementations of the Minecraft Server which all call
System.exit(0);
when their process is done. This change makes sure that the JVM shuts down properly, even if other threads might block an ordinary shutdown from happening (ie. Netty and other networking related tasks).Result
Services using the Minestom framework now properly shut down and allow CloudNet to advance to the next lifecycle steps.
Other context
Fixes #1304