CloudNet icon indicating copy to clipboard operation
CloudNet copied to clipboard

Fix: Make sure Minestom services stop like Bukkit services

Open GiantTreeLP opened this issue 1 year ago • 1 comments

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

GiantTreeLP avatar Dec 06 '23 19:12 GiantTreeLP

As of now, this solution also works on server implementations build on hollow-cube/minestom-ce.

GiantTreeLP avatar Dec 08 '23 18:12 GiantTreeLP

Can we maybe implement this as discussed here (https://discord.com/channels/713041279277203457/777861579659411466/1182967379488161872)

0utplay avatar May 16 '24 14:05 0utplay

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.

GiantTreeLP avatar May 16 '24 16:05 GiantTreeLP

@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.

GiantTreeLP avatar May 16 '24 18:05 GiantTreeLP

Thats because there are conflicts in the Wrapper class. I can resolve them later.

0utplay avatar May 16 '24 18:05 0utplay