Ensure the proxy doesn't shut down too early if stdin is EOF.

This commit is contained in:
Andrew Steinborn 2019-05-23 14:50:58 -04:00
parent b881e9cf04
commit df7eb4ade0
3 changed files with 13 additions and 0 deletions

View File

@ -45,5 +45,10 @@ public class Velocity {
double bootTime = (System.currentTimeMillis() - startTime) / 1000d;
logger.info("Done ({}s)!", new DecimalFormat("#.##").format(bootTime));
server.getConsoleCommandSource().start();
// 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
// main thread exits.
server.awaitProxyShutdown();
}
}

View File

@ -138,6 +138,10 @@ public class VelocityServer implements ProxyServer {
return commandManager;
}
void awaitProxyShutdown() {
cm.getBossGroup().terminationFuture().syncUninterruptibly();
}
@EnsuresNonNull({"serverKeyPair", "servers", "pluginManager", "eventManager", "scheduler",
"console", "cm", "configuration"})
void start() {

View File

@ -160,6 +160,10 @@ public final class ConnectionManager {
}
}
public EventLoopGroup getBossGroup() {
return bossGroup;
}
public ServerChannelInitializerHolder getServerChannelInitializer() {
return this.serverChannelInitializer;
}