diff --git a/easy-retry-server/src/main/java/com/aizuda/easy/retry/server/EasyRetryServerApplication.java b/easy-retry-server/src/main/java/com/aizuda/easy/retry/server/EasyRetryServerApplication.java index c3939ad9..438354d7 100644 --- a/easy-retry-server/src/main/java/com/aizuda/easy/retry/server/EasyRetryServerApplication.java +++ b/easy-retry-server/src/main/java/com/aizuda/easy/retry/server/EasyRetryServerApplication.java @@ -1,6 +1,7 @@ package com.aizuda.easy.retry.server; import com.aizuda.easy.retry.server.server.NettyHttpServer; +import lombok.extern.slf4j.Slf4j; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; @@ -14,10 +15,12 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.transaction.annotation.EnableTransactionManagement; import java.util.TimeZone; +import java.util.concurrent.TimeUnit; @SpringBootApplication @MapperScan("com.aizuda.easy.retry.server.persistence.mybatis.mapper") @EnableTransactionManagement(proxyTargetClass = true) +@Slf4j public class EasyRetryServerApplication { @Bean @@ -36,7 +39,16 @@ public class EasyRetryServerApplication { @Bean public ApplicationRunner nettyStartupChecker(NettyHttpServer nettyHttpServer, ServletWebServerFactory serverFactory) { return args -> { + // 最长自旋10秒,保证nettyHttpServer启动完成 + int waitCount = 0; + while (!nettyHttpServer.isStarted() || waitCount > 100) { + log.info("--------> easy-retry netty server is staring...."); + TimeUnit.MILLISECONDS.sleep(100); + waitCount++; + } + if (!nettyHttpServer.isStarted()) { + log.error("--------> easy-retry netty server startup failure."); // Netty启动失败,停止Web服务和Spring Boot应用程序 serverFactory.getWebServer().stop(); SpringApplication.exit(SpringApplication.run(EasyRetryServerApplication.class)); diff --git a/pom.xml b/pom.xml index 913a76a1..2c679b1c 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ 1.8 1.8 1.8 - 2.1.0 + 2.1.1 1.0.0 4.1.94.Final 5.8.19