Fix logs being cut off during shutdown

This commit is contained in:
P0nk
2022-06-19 07:50:35 +02:00
parent 45c9e6fc7e
commit 89ababc5c0
2 changed files with 7 additions and 2 deletions

View File

@@ -53,6 +53,7 @@ import net.server.guild.Guild;
import net.server.guild.GuildCharacter;
import net.server.task.*;
import net.server.world.World;
import org.apache.logging.log4j.LogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import server.CashShop.CashItemFactory;
@@ -1922,9 +1923,13 @@ public class Server {
TimerManager.getInstance().purge();
TimerManager.getInstance().stop();
log.info("World and channels are offline.");
log.info("Worlds and channels are offline.");
loginServer.stop();
if (!restart) { // shutdown hook deadlocks if System.exit() method is used within its body chores, thanks MIKE for pointing that out
// We disabled log4j's shutdown hook in the config file, so we have to manually shut it down here,
// after our last log statement.
LogManager.shutdown();
new Thread(() -> System.exit(0)).start();
} else {
log.info("Restarting the server...");

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" name="Cosmic">
<Configuration status="WARN" name="Cosmic" shutdownHook="disable">
<Properties>
<Property name="filename">cosmic-log</Property>
<Property name="standard-pattern">%d{HH:mm:ss.SSS} [%t] %-5level %logger{2} - %msg%n</Property>