In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to turn off Spring Boot". Interested friends may wish to take a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to turn off Spring Boot.
Gracefully shut down Spring Boot
1. Implement the TomcatConnectorCustomizer API to get the connection to Tomcat and obtain the Tomcat connection pool
2. Implement the ApplicationListener listener server shutdown event and register the JVM hook function to close the Tomcat connection pool
Considerations for using closed hooks
1. Closed hooks are essentially a thread (also known as hook threads), and they will be executed concurrently for multiple closed hooks registered in a JVM, so JVM does not guarantee their execution order; because they are executed concurrently, then problems such as race conditions or deadlocks are likely to occur because of improper code. In order to avoid this problem, it is strongly recommended to register only one hook and perform a series of operations in it. The 2.Hook thread will delay the shutdown time of the JVM, which requires that the execution time of the Hook thread must be reduced as much as possible in the process of writing the hook, so as to avoid the time-consuming calculation, waiting for the user ID O and other operations in the hook thread. 3. The shutdown hook may be forcibly interrupted during execution, for example, when the operating system shuts down, the operating system will wait for the process to stop, wait for the timeout, the process has not stopped, and the operating system will forcibly kill the process. In such cases, the shutdown hook is forcibly aborted during execution. 4. In closed hooks, registration and removal of hooks cannot be performed. JVM will not add or remove existing hooks again after the closed hook sequence is initialized, otherwise JVM throws an IllegalStateException exception. 5. System.exit () cannot be called on the hook, otherwise the closing process of JVM will be stuck, but Runtime.halt () can be called. Exceptions are also thrown in the 6.Hook thread, and for uncaught exceptions, the thread's default exception handler handles the exception (printing the exception information to System.err) without affecting other hook threads and JVM exiting normally.
At this point, I believe you have a deeper understanding of "how to turn off Spring Boot". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.