mdhtr / java-webapplication

Building a java web application step by step
0 stars 0 forks source link

Do proper graceful shutdown #1

Closed mdhtr closed 4 years ago

mdhtr commented 6 years ago

https://github.com/mdhtr/java-webapplication/blob/ce371b12d0ebc271e0a225f9951e2bad35b41fef/src/main/java/mdhtr/webapplication/JettyServer.java#L50

A colleague told me that the ServletContextHandler needs to be wrapped in a StatisticsHandler to know if the connections are busy or not. Without this the server will still shut down immediately.

With the existing code it would look like this:

HandlerWrapper statisticsHandler = new StatisticsHandler();
statisticsHandler.setHandler(createContextHandler());
server.setHandler(statisticsHandler);