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
Minestom server doesn't shut down correctly #1304
Labels
Comments
DasBabyPixel
added
s: needs triage
Issue waiting for triage
t: bug
Something isn't working as intended
labels
Aug 31, 2023
I can confirm that. We(CloudNet Devs and ME) discussed already that on discord. |
This was referenced Dec 6, 2023
0utplay
added a commit
that referenced
this issue
May 17, 2024
<!-- Thanks for taking your time and creating a pull request. Please note that we will not merge pull requests which are not following our code style (https://google.github.io/styleguide/javaguide.html). Most of these rules are checked while compile using checkstyle. On the other hand, please cover relevant code with tests. These are showing the maintainers what to expect from your pull requests and ensures that changes to your code will be consistent over time. See for example https://betterprogramming.pub/13-tips-for-writing-useful-unit-tests-ca20706b5368 if you need a bit of guidance while writing your tests. --> ### Motivation <!-- Explain the context and why you're making the change (what is the problem solved by this pr) --> 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 <!-- Describe the modification you've done to the codebase --> 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 <!-- Describe the result of the pull request (what changed compared to before) --> Services using the Minestom framework now properly shut down and allow CloudNet to advance to the next lifecycle steps. ##### Other context <!-- Other context of the pull request, a discussion, issue or anything else related --> Fixes #1304 --------- Co-authored-by: 0utplay <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Stacktrace
No response
Actions to reproduce
Set up a dummy minestom server that starts and stops. The wrapper will not stop because there are some threads that aren't daemons so the wrapper just won't stop even though the application has terminated
CloudNet version
[31.08 10:51:24.867] INFO:
[31.08 10:51:24.868] INFO: CloudNet Blizzard 4.0.0-RC9 f6ca4c3
[31.08 10:51:24.868] INFO: Discord: https://discord.cloudnetservice.eu/
[31.08 10:51:24.868] INFO:
[31.08 10:51:24.869] INFO: ClusterId: deebb2f9--41cd--246e55129822
[31.08 10:51:24.869] INFO: NodeId: Node-1
[31.08 10:51:24.869] INFO: Head-NodeId: Node-1
[31.08 10:51:24.870] INFO: CPU usage: (P/S) .36/.34/100%
[31.08 10:51:24.870] INFO: Node services memory allocation (U/R/M): 1536/1536/4096 MB
[31.08 10:51:24.871] INFO: Threads: 55
[31.08 10:51:24.871] INFO: Heap usage: 42/256MB
[31.08 10:51:24.871] INFO: JVM: Amazon.com Inc. 17 (OpenJDK 64-Bit Server VM 17.0.4.1+9-LTS)
[31.08 10:51:24.871] INFO: Update Repo: CloudNetService/launchermeta, Update Branch: beta
[31.08 10:51:24.872] INFO:
Other
A potential fix is to make all threads in the wrapper daemon threads. Should be fine because the node shouldn't care if the wrapper just stops responding
Issue uniqueness
Edit:
Here is a thread dump of all non-daemon threads
The problem is that the netty threads aren't daemon threads and only shut down after
System.exit
but not after all threads created by the minestom server have exited normally.System.exit
is a workaroundThe text was updated successfully, but these errors were encountered: