|
17 | 17 | import javax.net.ssl.SSLContext; |
18 | 18 |
|
19 | 19 | import edu.umd.cs.findbugs.annotations.NonNull; |
| 20 | +import edu.umd.cs.findbugs.annotations.Nullable; |
20 | 21 | import io.jooby.*; |
21 | 22 | import io.jooby.exception.StartupException; |
22 | 23 | import io.jooby.internal.netty.*; |
@@ -139,7 +140,11 @@ public Server start(@NonNull Jooby... application) { |
139 | 140 | var classLoader = applications.get(0).getClassLoader(); |
140 | 141 |
|
141 | 142 | var transport = NettyTransport.transport(classLoader); |
142 | | - eventLoop = new NettyEventLoopGroup(transport, singleEventLoopGroup, options.getIoThreads()); |
| 143 | + eventLoop = createEventLoopGroup(); |
| 144 | + if (eventLoop == null) { |
| 145 | + eventLoop = |
| 146 | + new NettyEventLoopGroupImpl(transport, singleEventLoopGroup, options.getIoThreads()); |
| 147 | + } |
143 | 148 |
|
144 | 149 | var outputFactory = (NettyOutputFactory) getOutputFactory(); |
145 | 150 | var allocator = outputFactory.getAllocator(); |
@@ -179,13 +184,17 @@ public Server start(@NonNull Jooby... application) { |
179 | 184 | return this; |
180 | 185 | } |
181 | 186 |
|
| 187 | + protected @Nullable NettyEventLoopGroup createEventLoopGroup() { |
| 188 | + return null; |
| 189 | + } |
| 190 | + |
182 | 191 | private ServerBootstrap newBootstrap( |
183 | 192 | ByteBufAllocator allocator, |
184 | 193 | NettyTransport transport, |
185 | 194 | NettyPipeline factory, |
186 | 195 | NettyEventLoopGroup group) { |
187 | 196 | return transport |
188 | | - .configure(eventLoop.getParent(), eventLoop.getChild()) |
| 197 | + .configure(group.getParent(), group.getChild()) |
189 | 198 | .childHandler(factory) |
190 | 199 | .childOption(ChannelOption.ALLOCATOR, allocator) |
191 | 200 | .childOption(ChannelOption.SO_REUSEADDR, true) |
@@ -226,20 +235,16 @@ public synchronized Server stop() { |
226 | 235 | // only for jooby build where close events may take longer. |
227 | 236 | NettyWebSocket.all.clear(); |
228 | 237 |
|
229 | | - eventLoop.shutdown(); |
| 238 | + if (eventLoop != null) { |
| 239 | + eventLoop.shutdown(); |
| 240 | + } |
230 | 241 | if (worker != null) { |
231 | 242 | worker.shutdown(); |
232 | 243 | worker = null; |
233 | 244 | } |
234 | 245 | return this; |
235 | 246 | } |
236 | 247 |
|
237 | | - private void shutdown(EventLoopGroup eventLoopGroup, int quietPeriod) { |
238 | | - if (eventLoopGroup != null) { |
239 | | - eventLoopGroup.shutdownGracefully(quietPeriod, 15, TimeUnit.SECONDS); |
240 | | - } |
241 | | - } |
242 | | - |
243 | 248 | private SslContext wrap( |
244 | 249 | SSLContext sslContext, ClientAuth clientAuth, String[] protocol, boolean http2) { |
245 | 250 | ApplicationProtocolConfig protocolConfig; |
|
0 commit comments