brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [04/13] incubator-brooklyn git commit: Startup option to exit once the app is deployed and running
Date Fri, 29 May 2015 10:36:04 GMT
Startup option to exit once the app is deployed and running

* Add an option exitAndLeaveAppsRunningAfterStarting to exit the process once the --app entity
is up and running
* Force a persist after launching is complete so that the app persistence is guaranteed before
exiting
* Pull the startup complete notification before starting the --app entity so that the progress
can be monitored in the console.


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

Branch: refs/heads/master
Commit: b9b8a977d61396f0f14133381d88cf6ce6b0a497
Parents: 776ad43
Author: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Authored: Fri May 22 21:22:34 2015 +0300
Committer: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Committed: Fri May 22 21:50:16 2015 +0300

----------------------------------------------------------------------
 usage/cli/src/main/java/brooklyn/cli/Main.java  | 22 +++++++++++++++-----
 .../brooklyn/launcher/BrooklynLauncher.java     | 10 +++++++--
 2 files changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b9b8a977/usage/cli/src/main/java/brooklyn/cli/Main.java
----------------------------------------------------------------------
diff --git a/usage/cli/src/main/java/brooklyn/cli/Main.java b/usage/cli/src/main/java/brooklyn/cli/Main.java
index d89703e..73d60f8 100644
--- a/usage/cli/src/main/java/brooklyn/cli/Main.java
+++ b/usage/cli/src/main/java/brooklyn/cli/Main.java
@@ -287,6 +287,11 @@ public class Main extends AbstractMain {
                 "allIfNotPersisted: stop all apps IF persistence is not enabled, otherwise
leave all running")
         public String stopWhichAppsOnShutdown = STOP_THESE_IF_NOT_PERSISTED;
 
+        @Option(name = { "--exitAndLeaveAppsRunningAfterStarting" },
+                description = "Once the application to start (from --app) is running exit
the process, leaving any entities running. "
+                    + "Can be used in combination with --persist auto --persistenceDir <custom
folder location> to attach to the running app at a later time.")
+        public boolean exitAndLeaveAppsRunningAfterStarting = false;
+
         /** @deprecated since 0.7.0 see {@link #stopWhichAppsOnShutdown} */
         @Deprecated
         @Option(name = { "-ns", "--noShutdownOnExit" },
@@ -438,8 +443,9 @@ public class Main extends AbstractMain {
                 Entities.dumpInfo(launcher.getApplications());
             }
             
-            waitAfterLaunch(ctx);
-
+            if (!exitAndLeaveAppsRunningAfterStarting) {
+                waitAfterLaunch(ctx);
+            }
             return null;
         }
 
@@ -511,18 +517,23 @@ public class Main extends AbstractMain {
         }
         
         protected StopWhichAppsOnShutdown computeStopWhichAppsOnShutdown() {
+            boolean isDefault = STOP_THESE_IF_NOT_PERSISTED.equals(stopWhichAppsOnShutdown);
             if (noShutdownOnExit) {
-                if (STOP_THESE_IF_NOT_PERSISTED.equals(stopWhichAppsOnShutdown)) {
+                if (isDefault) {
                     // the default; assume it was not explicitly specified so no error
                     stopWhichAppsOnShutdown = STOP_NONE;
                     // but warn of deprecation
                     log.warn("Deprecated paramater `--noShutdownOnExit` detected; this will
likely be removed in a future version; "
                         + "replace with `"+STOP_WHICH_APPS_ON_SHUTDOWN+" "+stopWhichAppsOnShutdown+"`");
+                    return StopWhichAppsOnShutdown.NONE;
                 } else {
                     throw new FatalConfigurationRuntimeException("Cannot specify both `--noShutdownOnExit`
and `"+STOP_WHICH_APPS_ON_SHUTDOWN+"`");
                 }
+            } else if (exitAndLeaveAppsRunningAfterStarting && isDefault) {
+                return StopWhichAppsOnShutdown.NONE;
+            } else {
+                return Enums.valueOfIgnoreCase(StopWhichAppsOnShutdown.class, stopWhichAppsOnShutdown).get();
             }
-            return Enums.valueOfIgnoreCase(StopWhichAppsOnShutdown.class, stopWhichAppsOnShutdown).get();
         }
         
         @VisibleForTesting
@@ -766,7 +777,8 @@ public class Main extends AbstractMain {
                     .add("persist", persist)
                     .add("persistenceLocation", persistenceLocation)
                     .add("persistenceDir", persistenceDir)
-                    .add("highAvailability", highAvailability);
+                    .add("highAvailability", highAvailability)
+                    .add("exitAndLeaveAppsRunningAfterStarting", exitAndLeaveAppsRunningAfterStarting);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b9b8a977/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java b/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
index 16f4f76..484c010 100644
--- a/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
+++ b/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
@@ -602,6 +602,10 @@ public class BrooklynLauncher {
         // resolution uses the catalog's classpath to scan for resolvers.)
         locations.addAll(managementContext.getLocationRegistry().resolve(locationSpecs));
 
+        // Already rebinded successfully, so previous apps are now available.
+        // Allow the startup to be visible in console for newly created apps.
+        ((LocalManagementContext)managementContext).noteStartupComplete();
+
         try {
             createApps();
             startApps();
@@ -617,8 +621,10 @@ public class BrooklynLauncher {
             }
         }
         
-        ((LocalManagementContext)managementContext).noteStartupComplete();
-
+        if (persistMode != PersistMode.DISABLED) {
+            // Make sure the new apps are persisted in case process exits immediately.
+            managementContext.getRebindManager().forcePersistNow(false, null);
+        }
         return this;
     }
 


Mime
View raw message