48 lines
1.3 KiB
Java
48 lines
1.3 KiB
Java
|
|
package com.maibu.netty;
|
|||
|
|
|
|||
|
|
import com.fastbee.memory.MiddleGlobalMemory;
|
|||
|
|
import io.vertx.core.Vertx;
|
|||
|
|
import io.vertx.core.VertxOptions;
|
|||
|
|
import lombok.Getter;
|
|||
|
|
import org.slf4j.Logger;
|
|||
|
|
import org.slf4j.LoggerFactory;
|
|||
|
|
import org.springframework.boot.CommandLineRunner;
|
|||
|
|
import org.springframework.stereotype.Component;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 系统初始化资源类
|
|||
|
|
* 实现CommandLineRunner接口,在Spring Boot启动时自动执行
|
|||
|
|
*/
|
|||
|
|
@Getter
|
|||
|
|
@Component
|
|||
|
|
public class InitResource implements CommandLineRunner {
|
|||
|
|
|
|||
|
|
private static final Logger logger = LoggerFactory.getLogger(InitResource.class);
|
|||
|
|
|
|||
|
|
@Override
|
|||
|
|
public void run(String... args) throws Exception {
|
|||
|
|
logger.info("InitResource 开始初始化系统资源...");
|
|||
|
|
|
|||
|
|
// 初始化Vert.x
|
|||
|
|
initVertx();
|
|||
|
|
logger.info("InitResource 系统资源初始化完成");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 初始化Vert.x
|
|||
|
|
*/
|
|||
|
|
private void initVertx() {
|
|||
|
|
try {
|
|||
|
|
VertxOptions options = new VertxOptions()
|
|||
|
|
.setWorkerPoolSize(20)
|
|||
|
|
.setEventLoopPoolSize(10)
|
|||
|
|
.setWarningExceptionTime(5000000000L);
|
|||
|
|
|
|||
|
|
MiddleGlobalMemory.vertx = Vertx.vertx(options);
|
|||
|
|
logger.info("Vert.x 初始化成功");
|
|||
|
|
} catch (Exception e) {
|
|||
|
|
logger.error("Vert.x 初始化失败: {}", e.getMessage(), e);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|