CloudNetService / CloudNet

A modern application that can dynamically and easily deliver Minecraft oriented software
https://cloudnetservice.eu
Apache License 2.0
371 stars 115 forks source link

fix: make sure Minestom services stop like Bukkit services #1338

Closed GiantTreeLP closed 3 months ago

GiantTreeLP commented 9 months ago

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 commented 9 months ago

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

0utplay commented 3 months ago

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

GiantTreeLP commented 3 months ago

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 commented 3 months ago

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

0utplay commented 3 months ago

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