From 414c2cdb2f3c5f86e50d2f72f97f019e2b79b466 Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 24 Apr 2018 02:09:12 +0900 Subject: [PATCH] ing --- src/main/java/com/loafle/commons/server/Server.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/loafle/commons/server/Server.java b/src/main/java/com/loafle/commons/server/Server.java index 4002ae7..7046226 100644 --- a/src/main/java/com/loafle/commons/server/Server.java +++ b/src/main/java/com/loafle/commons/server/Server.java @@ -67,20 +67,26 @@ public abstract class Server { this.init(); - ChannelFuture f = serverBootstrap.bind(address).sync(); + ChannelFuture cf = this.bind(serverBootstrap); + cf.sync(); this.onStart(); - f.channel().closeFuture().sync(); + cf.channel().closeFuture().sync(); + + this.onStop(); } catch (Exception e) { logger.error("Server", e); } finally { - this.onStop(); bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); this.destroy(); } } + protected ChannelFuture bind(ServerBootstrap serverBootstrap) throws Exception { + return serverBootstrap.bind(address); + } + protected abstract void init() throws Exception; protected abstract void onStart() throws Exception; protected abstract void onStop() throws Exception;