Handle logging during shutdown better on the server, by not

closing the logfile before the server itself has shutdown.

Signed-off-by: cpw <cpw+github@weeksfamily.ca>
This commit is contained in:
cpw 2019-10-26 16:55:15 -04:00
parent e3068d7db2
commit 862289cf56
No known key found for this signature in database
GPG key ID: 8EB3DF749553B1B7
3 changed files with 14 additions and 4 deletions

View file

@ -167,7 +167,15 @@
final DedicatedServer dedicatedserver = new DedicatedServer(new File(s), serverpropertiesprovider, DataFixesManager.func_210901_a(), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, playerprofilecache, LoggingChunkStatusListener::new, s1); final DedicatedServer dedicatedserver = new DedicatedServer(new File(s), serverpropertiesprovider, DataFixesManager.func_210901_a(), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, playerprofilecache, LoggingChunkStatusListener::new, s1);
dedicatedserver.func_71224_l(optionset.valueOf(optionspec7)); dedicatedserver.func_71224_l(optionset.valueOf(optionspec7));
dedicatedserver.func_71208_b(optionset.valueOf(optionspec10)); dedicatedserver.func_71208_b(optionset.valueOf(optionspec10));
@@ -948,7 +975,7 @@ @@ -904,6 +931,7 @@
Thread thread = new Thread("Server Shutdown Thread") {
public void run() {
dedicatedserver.func_71263_m(true);
+ LogManager.shutdown(); // we're manually managing the logging shutdown on the server. Make sure we do it here at the end.
}
};
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(field_147145_h));
@@ -948,7 +976,7 @@
} }
public ServerWorld func_71218_a(DimensionType p_71218_1_) { public ServerWorld func_71218_a(DimensionType p_71218_1_) {
@ -176,7 +184,7 @@
} }
public Iterable<ServerWorld> func_212370_w() { public Iterable<ServerWorld> func_212370_w() {
@@ -987,7 +1014,7 @@ @@ -987,7 +1015,7 @@
} }
public String getServerModName() { public String getServerModName() {
@ -185,7 +193,7 @@
} }
public CrashReport func_71230_b(CrashReport p_71230_1_) { public CrashReport func_71230_b(CrashReport p_71230_1_) {
@@ -1529,6 +1556,31 @@ @@ -1529,6 +1557,31 @@
public abstract boolean func_213199_b(GameProfile p_213199_1_); public abstract boolean func_213199_b(GameProfile p_213199_1_);

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" packages="net.minecrell.terminalconsole,net.minecrell.terminalconsole.util,com.mojang.util,cpw.mods.modlauncher.log"> <Configuration status="warn" packages="net.minecrell.terminalconsole,net.minecrell.terminalconsole.util,com.mojang.util,cpw.mods.modlauncher.log" shutdownHook="disable">
<filters> <filters>
<ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="NEUTRAL"/> <ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="NETWORK_PACKETS" onMatch="${sys:forge.logging.marker.networking:-DENY}" onMismatch="NEUTRAL"/> <MarkerFilter marker="NETWORK_PACKETS" onMatch="${sys:forge.logging.marker.networking:-DENY}" onMismatch="NEUTRAL"/>

View file

@ -86,6 +86,8 @@ public class ClientModLoader
public static void begin(final Minecraft minecraft, final ResourcePackList<ClientResourcePackInfo> defaultResourcePacks, final IReloadableResourceManager mcResourceManager, DownloadingPackFinder metadataSerializer) public static void begin(final Minecraft minecraft, final ResourcePackList<ClientResourcePackInfo> defaultResourcePacks, final IReloadableResourceManager mcResourceManager, DownloadingPackFinder metadataSerializer)
{ {
// force log4j to shutdown logging in a shutdown hook. This is because we disable default shutdown hook so the server properly logs it's shutdown
Runtime.getRuntime().addShutdownHook(new Thread(LogManager::shutdown));
loading = true; loading = true;
ClientModLoader.mc = minecraft; ClientModLoader.mc = minecraft;
SidedProvider.setClient(()->minecraft); SidedProvider.setClient(()->minecraft);