From 13773865cfdcb02e1405af96315cad97c9f41419 Mon Sep 17 00:00:00 2001 From: Charles Allen Date: Mon, 17 Aug 2015 17:39:48 -0700 Subject: [PATCH] Make jetty scheduler threads daemon thread --- .../druid/server/initialization/jetty/JettyServerModule.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/src/main/java/io/druid/server/initialization/jetty/JettyServerModule.java b/server/src/main/java/io/druid/server/initialization/jetty/JettyServerModule.java index 08d1e01e03d..45bd177251b 100644 --- a/server/src/main/java/io/druid/server/initialization/jetty/JettyServerModule.java +++ b/server/src/main/java/io/druid/server/initialization/jetty/JettyServerModule.java @@ -51,6 +51,7 @@ import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.util.thread.QueuedThreadPool; +import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; import javax.servlet.ServletException; import java.util.Map; @@ -161,6 +162,10 @@ public class JettyServerModule extends JerseyServletModule final Server server = new Server(threadPool); + // Without this bean set, the default ScheduledExecutorScheduler runs as non-daemon, causing lifecycle hooks to fail + // to fire on main exit. Related bug: https://github.com/druid-io/druid/pull/1627 + server.addBean(new ScheduledExecutorScheduler("JettyScheduler", true), true); + ServerConnector connector = new ServerConnector(server); connector.setPort(node.getPort()); connector.setIdleTimeout(Ints.checkedCast(config.getMaxIdleTime().toStandardDuration().getMillis()));