karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject karaf git commit: [KARAF-3441]The admin:stop Command Does Not Zero Out Root Container PID (cherry picked from commit 1561cb8c838ded48da5884193d99a47fd97eea70) (cherry picked from commit 9ede5e4e7c7f8ade3ac4be1050bf48b32c5a0e7b)
Date Mon, 12 Jan 2015 07:46:53 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-3.0.x 7831140ce -> f5f575d02


[KARAF-3441]The admin:stop Command Does Not Zero Out Root Container PID
(cherry picked from commit 1561cb8c838ded48da5884193d99a47fd97eea70)
(cherry picked from commit 9ede5e4e7c7f8ade3ac4be1050bf48b32c5a0e7b)

Conflicts:
	instance/core/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/f5f575d0
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/f5f575d0
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/f5f575d0

Branch: refs/heads/karaf-3.0.x
Commit: f5f575d02cf32ceb1d279b3f5e81f31105d84a2f
Parents: 7831140
Author: Freeman Fang <freeman.fang@gmail.com>
Authored: Mon Jan 12 15:32:48 2015 +0800
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Mon Jan 12 15:46:33 2015 +0800

----------------------------------------------------------------------
 .../core/internal/InstanceServiceImpl.java      | 30 +++++++++++++++++---
 1 file changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/f5f575d0/instance/core/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
----------------------------------------------------------------------
diff --git a/instance/core/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
b/instance/core/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
index fc4d49f..67ee8ea 100644
--- a/instance/core/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
+++ b/instance/core/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
@@ -483,8 +483,11 @@ public class InstanceServiceImpl implements InstanceService {
     }
 
     public void stopInstance(final String name) {
-        execute(new Task<Object>() {
+        
+        Integer pid = (Integer)execute(new Task<Object>() {
+            
             public Object call(State state) throws IOException {
+                int rootInstancePID = 0;
                 InstanceState instance = state.instances.get(name);
                 if (instance == null) {
                     throw new IllegalArgumentException("Instance " + name + " not found");
@@ -495,12 +498,31 @@ public class InstanceServiceImpl implements InstanceService {
                 }
                 cleanShutdown(instance);
                 if (instance.pid > 0) {
-                    Process process = new ProcessBuilderFactoryImpl().newBuilder().attach(instance.pid);
-                    process.destroy();
+                    if (!instance.root) {
+                        Process process = new ProcessBuilderFactoryImpl().newBuilder().attach(instance.pid);
+                        process.destroy();
+                    } else {
+                        //can't simply destroy root instance here
+                        //as it will lose the update in instances.properties
+                        //because of no chance to run the saveData
+                        rootInstancePID = instance.pid;
+                    }
+                    instance.pid = 0;
+                    
                 }
-                return null;
+                return rootInstancePID;
             }
         }, true);
+        if (pid.intValue() != 0 && isInstanceRoot(name)) {
+            Process process;
+            try {
+                process = new ProcessBuilderFactoryImpl().newBuilder().attach(pid.intValue());
+                process.destroy(); 
+            } catch (IOException e) {
+                LOGGER.debug("Unable to cleanly shutdown root instance ", e);
+            }
+                     
+        }
     }
 
     public void destroyInstance(final String name) {


Mime
View raw message