3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Shutdown logger to flush queue before call a System#exit

Dieser Commit ist enthalten in:
Leymooo 2018-08-30 14:34:30 +03:00
Ursprung b7725a7764
Commit 182c117dc5

Datei anzeigen

@ -50,6 +50,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
public class VelocityServer implements ProxyServer { public class VelocityServer implements ProxyServer {
private static final Logger logger = LogManager.getLogger(VelocityServer.class); private static final Logger logger = LogManager.getLogger(VelocityServer.class);
public static final Gson GSON = new GsonBuilder() public static final Gson GSON = new GsonBuilder()
.registerTypeHierarchyAdapter(Component.class, new GsonComponentSerializer()) .registerTypeHierarchyAdapter(Component.class, new GsonComponentSerializer())
@ -116,10 +117,12 @@ public class VelocityServer implements ProxyServer {
if (!configuration.validate()) { if (!configuration.validate()) {
logger.error("Your configuration is invalid. Velocity will refuse to start up until the errors are resolved."); logger.error("Your configuration is invalid. Velocity will refuse to start up until the errors are resolved.");
LogManager.shutdown();
System.exit(1); System.exit(1);
} }
} catch (IOException e) { } catch (IOException e) {
logger.error("Unable to load your velocity.toml. The server will shut down.", e); logger.error("Unable to load your velocity.toml. The server will shut down.", e);
LogManager.shutdown();
System.exit(1); System.exit(1);
} }
@ -192,7 +195,9 @@ public class VelocityServer implements ProxyServer {
} }
public void shutdown() { public void shutdown() {
if (!shutdownInProgress.compareAndSet(false, true)) return; if (!shutdownInProgress.compareAndSet(false, true)) {
return;
}
logger.info("Shutting down the proxy..."); logger.info("Shutting down the proxy...");
for (ConnectedPlayer player : ImmutableList.copyOf(connectionsByUuid.values())) { for (ConnectedPlayer player : ImmutableList.copyOf(connectionsByUuid.values())) {