mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-02-17 06:27:42 +01:00
Evil attempt at ensuring we coax logger to flush
This commit is contained in:
@@ -70,20 +70,31 @@ public class Velocity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final VelocityServer[] velocity = {null};
|
||||||
|
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||||
|
if (velocity[0] != null) {
|
||||||
|
velocity[0].shutdown(true);
|
||||||
|
} else {
|
||||||
|
LogManager.shutdown();
|
||||||
|
}
|
||||||
|
}, "Shutdown thread"));
|
||||||
|
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
|
|
||||||
VelocityServer server = new VelocityServer(options);
|
|
||||||
server.start();
|
velocity[0] = new VelocityServer(options);
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> server.shutdown(false),
|
velocity[0].start();
|
||||||
"Shutdown thread"));
|
|
||||||
|
|
||||||
|
|
||||||
double bootTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime) / 1000d;
|
double bootTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime) / 1000d;
|
||||||
logger.info("Done ({}s)!", new DecimalFormat("#.##").format(bootTime));
|
logger.info("Done ({}s)!", new DecimalFormat("#.##").format(bootTime));
|
||||||
server.getConsoleCommandSource().start();
|
velocity[0].getConsoleCommandSource().start();
|
||||||
|
|
||||||
// If we don't have a console available (because SimpleTerminalConsole returned), then we still
|
// If we don't have a console available (because SimpleTerminalConsole returned), then we still
|
||||||
// need to wait, otherwise the JVM will reap us as no non-daemon threads will be active once the
|
// need to wait, otherwise the JVM will reap us as no non-daemon threads will be active once the
|
||||||
// main thread exits.
|
// main thread exits.
|
||||||
server.awaitProxyShutdown();
|
velocity[0].awaitProxyShutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user