ソースを参照

netty close method update

shjung 13 時間 前
コミット
8a845d0fb1

+ 23 - 12
utic-its-common/src/main/java/com/utic/its/common/xnet/server/ItsAsnCommServer.java

@@ -41,7 +41,8 @@ public abstract class ItsAsnCommServer {
     public void run(int clusterId, Set<String> whiteListIps) {
         if (!OsPlatform.isWindows()) {
             if (!Epoll.isAvailable()) {
-                Epoll.unavailabilityCause().printStackTrace();
+//                Epoll.unavailabilityCause().printStackTrace();
+                log.warn("{}", Epoll.unavailabilityCause().getMessage());
             }
         }
         if (NettyUtils.isEpollAvailable()) {
@@ -51,11 +52,21 @@ public abstract class ItsAsnCommServer {
             log.info("The ASN.1 Communication Server runs in Windows NIO mode.");
         }
 
-        this.serverBootstrap = createBootstrap(clusterId, whiteListIps,
-                this.config.getAcceptThreads(),
-                this.config.getWorkerThreads(),
-                this.config.getBacklog(),
-                this.config.getConnectTimeoutSeconds());
+        try {
+            this.serverBootstrap = createBootstrap(clusterId, whiteListIps,
+                    this.config.getAcceptThreads(),
+                    this.config.getWorkerThreads(),
+                    this.config.getBacklog(),
+                    this.config.getConnectTimeoutSeconds());
+
+            this.acceptGroups = this.serverBootstrap.config().group();
+            this.workerGroups = this.serverBootstrap.config().childGroup();
+
+        } catch (Exception e) {
+            log.error("ItsAsnCommServer createBootstrap exception: {}", e.getMessage());
+            log.error("ItsAsnCommServer cannot be started. It will be terminated. *************************************");
+            return;
+        }
 
         log.info("*********************************************************************************");
         log.info("**              UTIC ASN.1 Communication Server Information                    **");
@@ -75,9 +86,9 @@ public abstract class ItsAsnCommServer {
             }
         }
         catch (Exception e) {
-            log.error("start, InterruptedException");
-            this.acceptGroups.shutdownGracefully();
-            this.workerGroups.shutdownGracefully();
+            log.error("ItsAsnCommServer bind exception: {}", e.getMessage());
+            if (this.acceptGroups != null) this.acceptGroups.shutdownGracefully();
+            if (this.workerGroups != null) this.workerGroups.shutdownGracefully();
         }
     }
 
@@ -89,7 +100,7 @@ public abstract class ItsAsnCommServer {
             }
         }
         catch (Exception e) {
-            log.info("ItsAsnCommServerService.acceptGroups.shutdownGracefully");
+            log.info("ItsAsnCommServer.acceptGroups.shutdownGracefully");
         }
         try {
             if (this.workerGroups != null) {
@@ -97,7 +108,7 @@ public abstract class ItsAsnCommServer {
             }
         }
         catch (Exception e) {
-            log.info("ItsAsnCommServerService.workerGroups.shutdownGracefully");
+            log.info("ItsAsnCommServer.workerGroups.shutdownGracefully");
         }
         try {
             if (this.channelFuture != null && this.channelFuture.channel() != null) {
@@ -105,7 +116,7 @@ public abstract class ItsAsnCommServer {
             }
         }
         catch (Exception e) {
-            log.info("ItsAsnCommServerService.closeFuture");
+            log.info("ItsAsnCommServer.closeFuture");
         }
     }