mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 23:15:49 +01:00
Merge pull request #1563 from t-tsutsumi/pr/fix-graceful-shutdown
Graceful shutdown on Jetty requires StatisticsHandler
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
import org.eclipse.jetty.server.Handler;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
|
import org.eclipse.jetty.server.handler.StatisticsHandler;
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -93,7 +95,9 @@ public class JettyLauncher {
|
|||||||
context.setInitParameter("org.scalatra.ForceHttps", "true");
|
context.setInitParameter("org.scalatra.ForceHttps", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
server.setHandler(context);
|
Handler handler = addStatisticsHandler(context);
|
||||||
|
|
||||||
|
server.setHandler(handler);
|
||||||
server.setStopAtShutdown(true);
|
server.setStopAtShutdown(true);
|
||||||
server.setStopTimeout(7_000);
|
server.setStopTimeout(7_000);
|
||||||
server.start();
|
server.start();
|
||||||
@@ -122,4 +126,12 @@ public class JettyLauncher {
|
|||||||
}
|
}
|
||||||
dir.delete();
|
dir.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Handler addStatisticsHandler(Handler handler) {
|
||||||
|
// The graceful shutdown is implemented via the statistics handler.
|
||||||
|
// See the following: https://bugs.eclipse.org/bugs/show_bug.cgi?id=420142
|
||||||
|
final StatisticsHandler statisticsHandler = new StatisticsHandler();
|
||||||
|
statisticsHandler.setHandler(handler);
|
||||||
|
return statisticsHandler;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user