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

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 232916c4dac7e8e04341a233b23b016f8a30c0f8
Author: Benoit Tellier <[email protected]>
AuthorDate: Mon Mar 9 09:25:05 2020 +0700

    JAMES-3108 Stop james server upon graceful shutdown
    
    James should not shut down immediatly on SIGTERM, but it gracefully 
terminates connections.
    
    In a kubernetes context for instance:
    
    ```
    It might take some time before a component such as kube-proxy or the 
Ingress controller is notified of the endpoint changes.
    
    Hence, traffic might still flow to the Pod despite it being marked as 
terminated.
    
    The app should stop accepting new requests on all remaining connections, 
and close these once the outgoing queue is drained.
    
    If you need a refresher on how endpoints are propagated in your cluster, 
read this article on how to handle client requests properly.
    ```
    
    (Source: https://learnk8s.io/production-best-practices)
    
    I think it also makes sens out of this context.
    
    A graceful shutdown furthermore decrease the risk of inconsistencies in the 
underlying datastores (Cassandra)
---
 .../guice-common/src/main/java/org/apache/james/JamesServerMain.java    | 2 ++
 1 file changed, 2 insertions(+)

diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/JamesServerMain.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/JamesServerMain.java
index fb9a653..357b380 100644
--- 
a/server/container/guice/guice-common/src/main/java/org/apache/james/JamesServerMain.java
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/JamesServerMain.java
@@ -32,5 +32,7 @@ public interface JamesServerMain {
         GuiceJamesServer server = 
GuiceJamesServer.forConfiguration(configuration)
             .combineWith(modules);
         server.start();
+        
+        Runtime.getRuntime().addShutdownHook(new Thread(server::stop));
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to