mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-07 16:12:02 +01:00
Fix issues with SIGTERM not shutting down gracefully - Fixes #3062
We had 2 issues. 1) Log4J2 Shutdown hook seemed to be causing issues as it shutdown logger while we still needed it 2) ServerShutdownThread needs to stay alive until server is shutdown to keep jvm open. It appears SIGINT is handled differently than SIGTERM, as SIGINT worked correctly. But this will make both methods work.
This commit is contained in:
parent
4347fa1b85
commit
0ded25feee
@ -79,6 +79,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
if (dedicatedserverproperties.announcePlayerAchievements != null) {
|
||||
((GameRules.GameRuleBoolean) this.getGameRules().get(GameRules.ANNOUNCE_ADVANCEMENTS)).a(dedicatedserverproperties.announcePlayerAchievements, (MinecraftServer) this);
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
||||
//this.remoteStatusListener.b(); // Paper - don't wait for remote connections
|
||||
}
|
||||
|
||||
+ hasFullyShutdown = true; // Paper
|
||||
System.exit(0); // CraftBukkit
|
||||
}
|
||||
|
||||
@@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
||||
@Override
|
||||
public void stop() {
|
||||
@ -122,6 +130,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
// Spigot start
|
||||
public static final int TPS = 20;
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||
|
||||
// CraftBukkit start
|
||||
private boolean hasStopped = false;
|
||||
+ public volatile boolean hasFullyShutdown = false; // Paper
|
||||
private final Object stopLock = new Object();
|
||||
public final boolean hasStopped() {
|
||||
synchronized (stopLock) {
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||
// CraftBukkit start - prevent double stopping on multiple threads
|
||||
synchronized(stopLock) {
|
||||
if (hasStopped) return;
|
||||
@ -431,6 +447,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ Thread.sleep(100);
|
||||
+ }
|
||||
+ if (server.hasStopped()) {
|
||||
+ while (!server.hasFullyShutdown) Thread.sleep(1000);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Looks stalled, close async
|
||||
@ -438,6 +455,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
org.spigotmc.AsyncCatcher.shuttingDown = true; // Paper
|
||||
+ server.forceTicks = true;
|
||||
server.close();
|
||||
+ while (!server.hasFullyShutdown) Thread.sleep(1000);
|
||||
+ } catch (InterruptedException e) {
|
||||
+ e.printStackTrace();
|
||||
+ // Paper end
|
||||
@ -534,3 +552,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
}
|
||||
break;
|
||||
} // Paper end
|
||||
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/resources/log4j2.xml
|
||||
+++ b/src/main/resources/log4j2.xml
|
||||
@@ -0,0 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
-<Configuration status="WARN" packages="com.mojang.util">
|
||||
+<Configuration status="WARN" packages="com.mojang.util" shutdownHook="disable">
|
||||
<Appenders>
|
||||
<Queue name="ServerGuiConsole">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n" />
|
||||
|
Loading…
Reference in New Issue
Block a user