Dropwizard:如何以编程方式关闭服务(进程中)?(Dropwizard: How to shutdown service programmatically (in

编程入门 行业动态 更新时间:2024-10-26 16:24:35
Dropwizard:如何以编程方式关闭服务(进程中)?(Dropwizard: How to shutdown service programmatically (in-process)?)

以编程方式关闭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.

更多推荐

本文发布于:2023-07-22 01:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1215508.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:进程   方式   Dropwizard   programmatically   service

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!