Commit 1d079da7 authored by p x's avatar p x
Browse files

修改启动配置参数

parent 2f6fd7c7
......@@ -498,3 +498,12 @@ Consider defining a bean of type 'com.inzy.wsmock.WebSocketHandler' in your conf
2026-01-08 17:07:38 [nioEventLoopGroup-3-4] INFO c.inzy.wsmock.NettyWebSocketServer.initChannel - ChannelPipeline顺序:[Entry, Entry, Entry, Entry, Entry, Entry, Entry, Entry, Entry]
2026-01-08 17:17:27 [SpringApplicationShutdownHook] INFO c.inzy.wsmock.NettyWebSocketServer.stop - Netty WebSocket服务已关闭
2026-01-08 17:17:27 [DefaultDispatcher-worker-1] INFO c.inzy.wsmock.NettyWebSocketServer.invokeSuspend - Netty线程组已关闭
2026-01-08 17:17:31 [main] INFO com.inzy.wsmock.WsmockApplicationKt.logStarting - Starting WsmockApplicationKt using Java 17.0.15 with PID 30132 (D:\JavaWorkSpace\wsmock\build\classes\kotlin\main started by Administrator in D:\JavaWorkSpace\wsmock)
2026-01-08 17:17:31 [main] INFO com.inzy.wsmock.WsmockApplicationKt.logStartupProfileInfo - No active profile set, falling back to 1 default profile: "default"
2026-01-08 17:17:32 [main] INFO o.a.catalina.core.StandardService.log - Starting service [Tomcat]
2026-01-08 17:17:32 [main] INFO o.a.catalina.core.StandardEngine.log - Starting Servlet engine: [Apache Tomcat/10.1.50]
2026-01-08 17:17:32 [main] INFO o.a.c.c.C.[Tomcat].[localhost].[/].log - Initializing Spring embedded WebApplicationContext
2026-01-08 17:17:32 [DefaultDispatcher-worker-1] INFO c.inzy.wsmock.NettyWebSocketServer.invokeSuspend - Netty WebSocket服务启动成功,端口:8089
2026-01-08 17:17:32 [main] INFO com.inzy.wsmock.WsmockApplicationKt.logStarted - Started WsmockApplicationKt in 1.035 seconds (process running for 1.385)
2026-01-08 17:19:38 [DefaultDispatcher-worker-1] INFO c.inzy.wsmock.NettyWebSocketServer.invokeSuspend - Netty线程组已关闭
2026-01-08 17:19:38 [SpringApplicationShutdownHook] INFO c.inzy.wsmock.NettyWebSocketServer.stop - Netty WebSocket服务已关闭
......@@ -11,6 +11,7 @@ import io.netty.handler.codec.http.HttpObjectAggregator
import io.netty.handler.codec.http.HttpServerCodec
import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler
import io.netty.handler.stream.ChunkedWriteHandler
import io.netty.util.concurrent.DefaultThreadFactory
import jakarta.annotation.PostConstruct
import jakarta.annotation.PreDestroy
import kotlinx.coroutines.CoroutineScope
......@@ -33,11 +34,12 @@ class NettyWebSocketServer(
private val logger = LoggerFactory.getLogger(javaClass)
private val websocketPath="/gs-guide-websocket"
private val websocketPath = "/gs-guide-websocket"
// Netty主从线程组
private val bossGroup = NioEventLoopGroup(1)
private val workerGroup = NioEventLoopGroup()
private val workerThreadNum = 1
private val workerGroup = NioEventLoopGroup(workerThreadNum, DefaultThreadFactory("netty-worker-thread"))
// 保存Netty服务的ChannelFuture,用于优雅关闭
private var serverChannelFuture: io.netty.channel.ChannelFuture? = null
......@@ -53,7 +55,7 @@ class NettyWebSocketServer(
val bootstrap = ServerBootstrap()
bootstrap.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel::class.java)
.option(ChannelOption.SO_BACKLOG, 1024)
.option(ChannelOption.SO_BACKLOG, 8192)
.childOption(ChannelOption.SO_KEEPALIVE, true)
.childHandler(object : ChannelInitializer<SocketChannel>() {
override fun initChannel(ch: SocketChannel) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment