13
0
geforkt von Mirrors/Velocity

Merge pull request #62 from Leymooo/logger

Shutdown logger to flush queue before call a System#exit
Dieser Commit ist enthalten in:
Andrew Steinborn 2018-08-30 15:35:46 -04:00 committet von GitHub
Commit ded384bbaa
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

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())) {