You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/08/18 08:49:11 UTC

[GitHub] liubao68 closed pull request #33: add shutdown graceful

liubao68 closed pull request #33: add shutdown graceful
URL: https://github.com/apache/incubator-servicecomb-docs/pull/33
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/java-chassis-reference/en_US/SUMMARY.md b/java-chassis-reference/en_US/SUMMARY.md
index caac364..cd45834 100644
--- a/java-chassis-reference/en_US/SUMMARY.md
+++ b/java-chassis-reference/en_US/SUMMARY.md
@@ -51,6 +51,7 @@
   * [DNS自定义配置](general-development/dnsconfig.md)
   * [代理设置](general-development/dai-li-she-zhi.md)
   * [框架上报版本号](general-development/report-framework-version.md)
+  * [Shutdown gracefully](general-development/shutdown.md)
 * [服务能力开放](catalog/open-service.md)
   * [使用confd和Nginx做边缘服务](edge/nginx.md)
   * [使用zuul做边缘服务](edge/zuul.md)
@@ -70,6 +71,3 @@
   * [Spring MVC模式的差异](using-java-chassis-in-spring-boot/diff-spring-mvc.md)
 * [常见问题](question-and-answer/question_answer.md)
   * [微服务接口兼容常见问题](question-and-answer/interface-compatibility.md)
-
-
-
diff --git a/java-chassis-reference/en_US/general-development/shutdown.md b/java-chassis-reference/en_US/general-development/shutdown.md
new file mode 100644
index 0000000..36e32c7
--- /dev/null
+++ b/java-chassis-reference/en_US/general-development/shutdown.md
@@ -0,0 +1,30 @@
+# Shutdown gracefully
+ServiceComb achieve graceful shutdown through JDK's ShutdownHook.
+
+## Scenes
+
+Graceful shutdown can solve the following scenes:
+* KILL PID
+* Application automatically exits unexpectedly(System.exit(n))
+
+Graceful shutdown can't solve the following scenes:
+* KILL -9 PID or taskkill /f /pid
+
+## Effect
+When triggering graceful shutdown:
+* Provider:
+  * Mark the current service status as STOPPING, do not accept new client requests, the new request will report error directly on the client, and the client cooperates with the retry mechanism to retry other instances;
+  * Wait for the currently running thread to finish executing. If the provider side has set timeout, will be forced to close after timeout;
+* consumer:
+  * Mark the current service state as STOPPING, do not send a new call request;
+  * Waiting for the response of the currently sent request, if it exceeds the timeout period for the client to receive the response (default 30 seconds), it is forcibly closed;
+
+## Principle
+When an graceful shutdown is triggered, the following steps are performed in sequence:
+1. Send a BEFORE_CLOSE event to all listeners, and notify the listener to handle the corresponding event;
+2. Mark the current service status as STOPPING;
+3. Log out the current microservice instance from the service center and close the vertx corresponding registry;
+4. Waiting for all currently existing invocation calls to complete;
+5. Close the vertx corresponding to config-center and transport;
+6. Send an AFTER_CLOSE event to all listeners, and notify the listener to handle the corresponding event;
+7. Mark the current service status as DOWN; graceful shutdown ends;
diff --git a/java-chassis-reference/zh_CN/SUMMARY.md b/java-chassis-reference/zh_CN/SUMMARY.md
index b1631df..5322d7b 100644
--- a/java-chassis-reference/zh_CN/SUMMARY.md
+++ b/java-chassis-reference/zh_CN/SUMMARY.md
@@ -60,6 +60,7 @@
   * [返回值序列化扩展](general-development/produceprocess.md)
   * [CORS机制](general-development/CORS.md)
   * [获取熔断与实例隔离告警事件信息](general-development/AlarmEvent.md)
+  * [优雅停机](general-development/shutdown.md)
 * [服务能力开放](edge/open-service.md)
   * [使用Edge Service做边缘服务](edge/by-servicecomb-sdk.md)
   * [使用confd和Nginx做边缘服务](edge/nginx.md)
diff --git a/java-chassis-reference/zh_CN/general-development/shutdown.md b/java-chassis-reference/zh_CN/general-development/shutdown.md
new file mode 100644
index 0000000..7219ff7
--- /dev/null
+++ b/java-chassis-reference/zh_CN/general-development/shutdown.md
@@ -0,0 +1,30 @@
+# 优雅停机
+ServiceComb是通过JDK的ShutdownHook来完成优雅停机的。
+
+## 使用场景
+
+优雅停机可以解决以下场景:
+* KILL PID
+* 应用意外自动退出(System.exit(n))
+
+优雅停机解决不了以下场景:
+* KILL -9 PID 或 taskkill /f /pid
+
+## 效果
+触发优雅停机时:
+* 服务提供者:
+  * 标记当前服务状态为STOPPING,不接受新的客户端请求,新的客户端访问请求会在客户端直接报错,客户端配合重试机制可重试其他实例;
+  * 等待当前已运行线程执行完毕,如果设置了provider端超时,超时则强制关闭;
+* 服务消费者:
+  * 标记当前服务状态为STOPPING,直接拒绝新的调用请求;
+  * 等待当前已发送请求的响应,如果超过客户端接收响应的超时时间(默认30秒),则强制关闭;
+
+## 原理
+触发优雅停机时,会依次执行以下步骤:
+1. 给所有listener下发BEFORE_CLOSE事件,通知listener处理对应事件;
+2. 将当前服务状态标记为STOPPING;
+3. 从服务中心注销当前微服务实例,并关闭registry对应vertx;
+4. 等待所有当前已存在invocation调用完成;
+5. 关闭config-center和transport对应vertx;
+6. 给所有listener下发AFTER_CLOSE事件,通知listener处理对应事件;
+7. 将当前服务状态标记为DOWN;优雅停机结束;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services