Explicitly exit the proxy if required.

This commit is contained in:
Andrew Steinborn
2018-11-14 01:07:34 -05:00
parent 5e0b9d09e7
commit 2b0daa2122
4 changed files with 8 additions and 4 deletions

View File

@@ -20,7 +20,7 @@ public class Velocity {
VelocityServer server = new VelocityServer();
server.start();
Runtime.getRuntime().addShutdownHook(new Thread(server::shutdown, "Shutdown thread"));
Runtime.getRuntime().addShutdownHook(new Thread(() -> server.shutdown(false), "Shutdown thread"));
double bootTime = (System.currentTimeMillis() - startTime) / 1000d;
logger.info("Done ({}s)!", new DecimalFormat("#.##").format(bootTime));

View File

@@ -229,7 +229,7 @@ public class VelocityServer implements ProxyServer {
return shutdown;
}
public void shutdown() {
public void shutdown(boolean explicitExit) {
if (eventManager == null || pluginManager == null || cm == null || scheduler == null) {
throw new AssertionError();
}
@@ -256,6 +256,10 @@ public class VelocityServer implements ProxyServer {
}
shutdown = true;
if (explicitExit) {
System.exit(0);
}
}
public NettyHttpClient getHttpClient() {

View File

@@ -22,7 +22,7 @@ public class ShutdownCommand implements Command {
.sendMessage(TextComponent.of("You are not allowed to use this command.", TextColor.RED));
return;
}
server.shutdown();
server.shutdown(true);
}
@Override

View File

@@ -88,7 +88,7 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Comm
@Override
protected void shutdown() {
this.server.shutdown();
this.server.shutdown(true);
}
}