以编程方式关闭Dropwizard服务的最佳做法是什么,例如,如果在任何线程中发生未捕获的异常,我想终止我的Dropwizard服务?
仅供参考:StackOverflow上类似但无关的问题:
这个问题Dropwizard:如何以编程方式停止服务与单元测试您的服务有关
这个问题如何关闭dropwizard应用程序? 涉及如何在进程外关闭服务。
What's the best practice to shutdown a Dropwizard service programmatically, e.g if an uncaught exception occurs in any thread I would like to terminate my Dropwizard service?
FYI: Similar but unrelated questions on StackOverflow:
This question Dropwizard: How to stop service programmatically relates to unit testing your service
This question How to shutdown dropwizard application? relates to how to shutdown your service out-of-process.
最满意答案
我认为那里还没有最好的做法。
System.exit(0);这就是CTRL-C所做的。 它调用关闭挂钩并导致正常关闭。
I don't think there is any best practice out there yet.
System.exit(0);This is what CTRL-C does. It calls the shutdown hooks and leads to graceful shutdown.
更多推荐
发布评论