久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

服務器spring boot版本,,平滑升級

 印度阿三17 2019-09-20

1,、在pom文件中加入:

<!--平滑升級包 開始 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--平滑升級包 結(jié)束 -->

2、在spring配置文件中:

#平滑關閉配置開始
management.endpoint.shutdown.enabled=true
management.endpoints.web.exposure.include=*
#平滑關閉配置結(jié)束

3,、定制controller

import org.apache.catalina.connector.Connector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextClosedEvent;

import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
* 定制的 Connector(tomcat處理器)
*
*/
@Configuration
public class CustomShutdown implements TomcatConnectorCustomizer, ApplicationListener<ContextClosedEvent> {

protected final Logger logger = LoggerFactory.getLogger(this.getClass());

private static final int TIMEOUT = 30;

private volatile Connector connector;

@Override
public void onApplicationEvent(ContextClosedEvent event) {
this.connector.pause();
Executor executor = this.connector.getProtocolHandler().getExecutor();
if (executor instanceof ThreadPoolExecutor) {
try {
logger.warn("WEB 應用準備關閉");
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executor;
threadPoolExecutor.shutdown();
if (!threadPoolExecutor.awaitTermination(TIMEOUT, TimeUnit.SECONDS)) {
logger.warn("WEB 應用等待關閉超過最大時長 " TIMEOUT " 秒,,將進行強制關閉!");
threadPoolExecutor.shutdownNow();
if (!threadPoolExecutor.awaitTermination(TIMEOUT, TimeUnit.SECONDS)) {
logger.error("WEB 應用關閉失敗!");
}
}
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
}

@Override
public void customize(Connector connector) {
this.connector = connector;
}
}

4、在spring啟動類中加入

@Bean
public CustomShutdown customShutdown() {
return new CustomShutdown();
}

/**
* 將定制的添加到tomcat
* @param customShutdown
* @return
*/
@Bean
public ConfigurableServletWebServerFactory webServerFactory(CustomShutdown customShutdown) {
TomcatServletWebServerFactory tomcatServletWebServerFactory = new TomcatServletWebServerFactory();
tomcatServletWebServerFactory.addConnectorCustomizers(customShutdown);
return tomcatServletWebServerFactory;
}

完成

來源:https://www./content-4-461001.html

    本站是提供個人知識管理的網(wǎng)絡存儲空間,,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式,、誘導購買等信息,,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點擊一鍵舉報,。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多