From 34a48dd9a0356d95dc5e9557462d0131fdc65eb1 Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Sat, 25 Jun 2022 16:36:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=91=E6=8E=A7=E9=80=82=E9=85=8Dnetty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/hippo4j/config/netty/MonitorNettyServer.java | 10 +++++++--- .../src/main/resources/application.properties | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/netty/MonitorNettyServer.java b/hippo4j-config/src/main/java/cn/hippo4j/config/netty/MonitorNettyServer.java index 87a4d7dc..b39e04e5 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/netty/MonitorNettyServer.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/netty/MonitorNettyServer.java @@ -22,6 +22,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; import java.util.concurrent.ThreadPoolExecutor; /** @@ -66,10 +67,13 @@ public class MonitorNettyServer { channelFuture.channel().closeFuture().sync(); } catch (Exception e) { log.error("nettyServerInit error",e); - } finally { - bossGroup.shutdownGracefully(); - workGroup.shutdownGracefully(); } },"nettyServerInit thread").start(); } + + @PreDestroy + public void destroy(){ + bossGroup.shutdownGracefully(); + workGroup.shutdownGracefully(); + } } diff --git a/hippo4j-example/hippo4j-spring-boot-starter-example/src/main/resources/application.properties b/hippo4j-example/hippo4j-spring-boot-starter-example/src/main/resources/application.properties index 12bf0d10..03aceebe 100644 --- a/hippo4j-example/hippo4j-spring-boot-starter-example/src/main/resources/application.properties +++ b/hippo4j-example/hippo4j-spring-boot-starter-example/src/main/resources/application.properties @@ -7,7 +7,7 @@ spring.application.name=dynamic-threadpool-example spring.dynamic.thread-pool.server-addr=http://localhost:6691 spring.dynamic.thread-pool.netty-server-port=8899 -#spring.dynamic.thread-pool.report-type=netty +spring.dynamic.thread-pool.report-type=netty spring.dynamic.thread-pool.namespace=prescription spring.dynamic.thread-pool.item-id=dynamic-threadpool-example spring.dynamic.thread-pool.username=admin