ing
This commit is contained in:
parent
68763a3c73
commit
414c2cdb2f
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user