[
https://issues.apache.org/jira/browse/SCB-548?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16471665#comment-16471665
]
ASF GitHub Bot commented on SCB-548:
------------------------------------
zhengyangyong commented on issue #693: [SCB-548] support gracefully shutdown
URL:
https://github.com/apache/incubator-servicecomb-java-chassis/pull/693#issuecomment-388301667
improve gracefully shutdown process order
```java
private void gracefullyShutdown() {
//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 3: wait all invocation finished
try {
ShutdownHookHandler.INSTANCE.ALL_INVOCATION_FINISHED.acquire();
LOGGER.warn("all invocation finished");
} catch (InterruptedException e) {
LOGGER.error("invocation finished semaphore interrupted", e);
}
//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);
}
```
----------------------------------------------------------------
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:
[email protected]
> Support Gracefully Shutdown
> ---------------------------
>
> Key: SCB-548
> URL: https://issues.apache.org/jira/browse/SCB-548
> Project: Apache ServiceComb
> Issue Type: Improvement
> Components: Java-Chassis
> Affects Versions: java-chassis-1.0.0-m2
> Reporter: yangyongzheng
> Assignee: yangyongzheng
> Priority: Major
>
> We did not implement gracefully shutdown yet:
> ```java
> // 当程序退出时,进行相关清理,注意:kill -9 {pid}下无效
> // 1. 去注册实例信息
> // TODO 服务优雅退出
> if (applicationContext instanceof AbstractApplicationContext) {
> ((AbstractApplicationContext)
> applicationContext).registerShutdownHook();
> }
> ```
>
> And had got an issue :
> https://github.com/apache/incubator-servicecomb-java-chassis/issues/685 from
> user.
> So it's time we must do it and remove this TODO
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)