Skip to content

Commit

Permalink
Merge pull request #1637 from metamx/peonPlaysNiceOnShutdown
Browse files Browse the repository at this point in the history
Make jetty scheduler threads daemon thread
  • Loading branch information
nishantmonu51 committed Sep 2, 2015
2 parents 0096e6a + 1377386 commit e79572b
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
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;
Expand Down Expand Up @@ -161,6 +162,10 @@ private static Server makeJettyServer(@Self DruidNode node, ServerConfig config)

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()));
Expand Down

0 comments on commit e79572b

Please sign in to comment.