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

dpavlov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git


The following commit(s) were added to refs/heads/master by this push:
     new 712a13a  Trying to add hook to wait CP end
712a13a is described below

commit 712a13a3acbfc8f2656b26e2b5a194415bc65265
Author: Dmitriy Pavlov <[email protected]>
AuthorDate: Fri Sep 21 13:26:19 2018 +0300

    Trying to add hook to wait CP end
---
 .../java/org/apache/ignite/ci/web/Launcher.java     | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/Launcher.java 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/Launcher.java
index 5c357a3..6bb5d71 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/Launcher.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/Launcher.java
@@ -72,19 +72,28 @@ public class Launcher {
             boolean stop = waitStopSignal();
 
             if (stop) {
-                try {
-                    server.stop();
-                }
-                catch (Exception e) {
-                    e.printStackTrace();
-                }
+                stopSilent(server);
             }
 
         };
+
+        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+            stopSilent(server);
+        }));
+
         new Thread(r).start();
         server.start();
     }
 
+    public static void stopSilent(Server server) {
+        try {
+            server.stop();
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
     public static boolean waitStopSignal() {
         Console cons = System.console();
         if (cons != null) {

Reply via email to