wait for netty to finish shutting down

This commit is contained in:
Eoghanmc22 2020-11-25 20:13:38 -05:00
parent ae845e38ab
commit 338a1737c7
2 changed files with 17 additions and 3 deletions

View File

@ -217,10 +217,22 @@ public final class NettyServer {
* Stops the server and the various services.
*/
public void stop() {
this.serverChannel.close();
try {
this.serverChannel.close().sync();
} catch (InterruptedException e) {
e.printStackTrace();
}
this.worker.shutdownGracefully();
this.boss.shutdownGracefully();
try {
this.worker.shutdownGracefully().await();
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
this.boss.shutdownGracefully().await();
} catch (InterruptedException e) {
e.printStackTrace();
}
this.trafficScheduler.shutdown();
this.globalTrafficHandler.release();

View File

@ -70,6 +70,8 @@ public class Main {
//MojangAuth.init();
minecraftServer.start("0.0.0.0", 25565, PlayerInit.getResponseDataConsumer());
Runtime.getRuntime().addShutdownHook(new Thread(MinecraftServer::stopCleanly));
}
}