feat: 2.1.1

1. 修复windows操作系统启动失败问题
This commit is contained in:
byteblogs168 2023-08-17 15:52:24 +08:00
parent 93ba73cb85
commit 64e962bc8f
2 changed files with 13 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package com.aizuda.easy.retry.server; package com.aizuda.easy.retry.server;
import com.aizuda.easy.retry.server.server.NettyHttpServer; import com.aizuda.easy.retry.server.server.NettyHttpServer;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
@ -14,10 +15,12 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
@SpringBootApplication @SpringBootApplication
@MapperScan("com.aizuda.easy.retry.server.persistence.mybatis.mapper") @MapperScan("com.aizuda.easy.retry.server.persistence.mybatis.mapper")
@EnableTransactionManagement(proxyTargetClass = true) @EnableTransactionManagement(proxyTargetClass = true)
@Slf4j
public class EasyRetryServerApplication { public class EasyRetryServerApplication {
@Bean @Bean
@ -36,7 +39,16 @@ public class EasyRetryServerApplication {
@Bean @Bean
public ApplicationRunner nettyStartupChecker(NettyHttpServer nettyHttpServer, ServletWebServerFactory serverFactory) { public ApplicationRunner nettyStartupChecker(NettyHttpServer nettyHttpServer, ServletWebServerFactory serverFactory) {
return args -> { 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()) { if (!nettyHttpServer.isStarted()) {
log.error("--------> easy-retry netty server startup failure.");
// Netty启动失败停止Web服务和Spring Boot应用程序 // Netty启动失败停止Web服务和Spring Boot应用程序
serverFactory.getWebServer().stop(); serverFactory.getWebServer().stop();
SpringApplication.exit(SpringApplication.run(EasyRetryServerApplication.class)); SpringApplication.exit(SpringApplication.run(EasyRetryServerApplication.class));

View File

@ -21,7 +21,7 @@
<java.version>1.8</java.version> <java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<revision>2.1.0</revision> <revision>2.1.1</revision>
<dingding-talk.version>1.0.0</dingding-talk.version> <dingding-talk.version>1.0.0</dingding-talk.version>
<netty-all.version>4.1.94.Final</netty-all.version> <netty-all.version>4.1.94.Final</netty-all.version>
<hutool-all.version>5.8.19</hutool-all.version> <hutool-all.version>5.8.19</hutool-all.version>