[ 
https://issues.apache.org/jira/browse/SCB-548?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16478654#comment-16478654
 ] 

ASF GitHub Bot commented on SCB-548:
------------------------------------

zhengyangyong opened a new pull request #693: [SCB-548] support gracefully 
shutdown
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/693
 
 
   Signed-off-by: zhengyangyong <yangyong.zh...@huawei.com>
   
   Follow this checklist to help us incorporate your contribution quickly and 
easily:
   
    - [x] Make sure there is a [JIRA 
issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually 
before you start working on it).  Trivial changes like typos do not require a 
JIRA issue.  Your pull request should address just this issue, without pulling 
in other changes.
    - [x] Each commit in the pull request should have a meaningful subject line 
and body.
    - [x] Format the pull request title like `[SCB-XXX] Fixes bug in 
ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA 
issue.
    - [x] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
    - [x] Run `mvn clean install` to make sure basic checks pass. A more 
thorough check will be performed on your pull request automatically.
    - [x] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   ---
   When user call system.exit(0),these three works will do:
   1.Unregister microservice instance from Service Center:
   this work will do by process ContextClosedEvent, we need unregister 
immediately for stopping provide service any more.
   2.Waiting for all invocations to finish:
   this work will do by ShutdownHandler, when all invocations finished or 
'deadline time reached', cc and transport vertx threads will close.
   3.All spring bean do close process
   we had registerShutdownHook for spring ApplicationContext and beans can 
define 'destroy-method' do cleaning.
   
   here is example:
    
   Spring mvc Hello Java Chassis
   Pojo Hello person ServiceComb/Java Chassis
   Jaxrs Hello person ServiceComb/Java Chassis
   Spring mvc Hello person ServiceComb/Java Chassis
   2018-05-09 16:02:14,288 [WARN] handler chain is shutting down 
org.apache.servicecomb.core.handler.ShutdownHookHandler.run(ShutdownHookHandler.java:87)
   2018-05-09 16:02:14,289 [INFO] Closing 
org.springframework.context.support.ClassPathXmlApplicationContext@7cf10a6f: 
startup date [Wed May 09 16:02:05 CST 2018]; root of context hierarchy 
org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:984)
   2018-05-09 16:02:14,290 [WARN] cse is closing now... 
org.apache.servicecomb.core.CseApplicationListener.onApplicationEvent(CseApplicationListener.java:148)
   2018-05-09 16:02:14,291 [INFO] service center task is shutdown. 
org.apache.servicecomb.serviceregistry.registry.RemoteServiceRegistry.onShutdown(RemoteServiceRegistry.java:72)
   2018-05-09 16:02:14,295 [WARN] handler chain is shut down 
org.apache.servicecomb.core.handler.ShutdownHookHandler.run(ShutdownHookHandler.java:103)
   2018-05-09 16:02:14,296 [INFO] Unregister microservice instance success. 
microserviceId=90b76fd551c511e8b51db4b676a39f40 
instanceId=481f630d535f11e8bc19b4b676a39f40 
org.apache.servicecomb.serviceregistry.registry.AbstractServiceRegistry.unregisterInstance(AbstractServiceRegistry.java:232)
   Process finished with exit code 0

----------------------------------------------------------------
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:
us...@infra.apache.org


> 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
>             Fix For: java-chassis-1.0.0-m2
>
>
> 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)

Reply via email to