first commit
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package com.maibu;
|
||||
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.dtflys.forest.springboot.annotation.ForestScan;
|
||||
import com.fastbee.netty.NettyServer;
|
||||
import com.fastbee.websocket.WebsocketHandler;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
/**
|
||||
* 启动程序
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@SpringBootApplication(exclude = { DruidDataSourceAutoConfigure.class })
|
||||
@ForestScan(basePackages = "com.maibu")
|
||||
public class MiddlePlatformApplication
|
||||
{
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// System.setProperty("spring.devtools.restart.enabled", "false");
|
||||
ConfigurableApplicationContext context = SpringApplication.run(MiddlePlatformApplication.class, args);
|
||||
|
||||
WebsocketHandler websocketHandler = new WebsocketHandler(9002);
|
||||
websocketHandler.start();
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
// 关闭WebSocket服务(核心:释放9002端口)
|
||||
System.out.println("开始释放websocket资源");
|
||||
try {
|
||||
websocketHandler.stopServer();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// 关闭Spring上下文
|
||||
context.close();
|
||||
}, "shutdown-hook-thread"));
|
||||
|
||||
NettyServer nettyServer = context.getBean(NettyServer.class);
|
||||
nettyServer.start();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user