This is an automated email from the ASF dual-hosted git repository.

wujimin pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit f1f277240ef187de97643a14e68dd05efbf0556e
Author: zhengyangyong <yangyong.zh...@huawei.com>
AuthorDate: Fri May 11 16:43:15 2018 +0800

    SCB-548 improve gracefully shutdown process order
    
    Signed-off-by: zhengyangyong <yangyong.zh...@huawei.com>
---
 .../org/apache/servicecomb/core/CseApplicationListener.java | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git 
a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java 
b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java
index 24da8c2..5d40780 100644
--- a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java
+++ b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java
@@ -153,12 +153,14 @@ public class CseApplicationListener
   }
 
   private void gracefullyShutdown() {
-    //Step 1: Unregister microservice instance from Service Center and close 
vertx
-    //        We need unregister from service center immediately
+    //Step 1: notify all component stop invoke via BEFORE_CLOSE Event
+    triggerEvent(EventType.BEFORE_CLOSE);
+
+    //Step 2: Unregister microservice instance from Service Center and close 
vertx
     RegistryUtils.destroy();
     VertxUtils.closeVertxByName("registry");
 
-    //Step 2: wait all invocation finished
+    //Step 3: wait all invocation finished
     try {
       ShutdownHookHandler.INSTANCE.ALL_INVOCATION_FINISHED.acquire();
       LOGGER.warn("all invocation finished");
@@ -166,15 +168,12 @@ public class CseApplicationListener
       LOGGER.error("invocation finished semaphore interrupted", e);
     }
 
-    //Step 3: notify all component do clean works via Event
-    triggerEvent(EventType.BEFORE_CLOSE);
-
     //Step 4: Stop vertx to prevent blocking exit
     VertxUtils.closeVertxByName("config-center");
     VertxUtils.closeVertxByName("transport");
 
+    //Step 5: notify all component do clean works via AFTER_CLOSE Event
     triggerEvent(EventType.AFTER_CLOSE);
-    ShutdownHookHandler.INSTANCE.ALL_INVOCATION_FINISHED.release();
   }
 
 

-- 
To stop receiving notification emails like this one, please contact
wuji...@apache.org.

Reply via email to