You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by gr...@apache.org on 2014/08/21 18:01:24 UTC

[09/11] git commit: Added command line config key to replace entire Node.JS start command string

Added command line config key  to replace entire Node.JS start command string


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

Branch: refs/heads/master
Commit: 2ce9c52811dacb21a1f10ea1fbb66e95cd2e83c2
Parents: a97b768
Author: Andrew Kennedy <gr...@apache.org>
Authored: Fri Aug 15 16:48:14 2014 +0100
Committer: Andrew Kennedy <gr...@apache.org>
Committed: Thu Aug 21 14:50:27 2014 +0100

----------------------------------------------------------------------
 .../entity/webapp/nodejs/NodeJsWebAppService.java      |  5 ++++-
 .../entity/webapp/nodejs/NodeJsWebAppSshDriver.java    | 13 +++++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2ce9c528/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
index 7e6b840..1711563 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
@@ -58,7 +58,10 @@ public interface NodeJsWebAppService extends SoftwareProcess, WebAppService {
     ConfigKey<String> APP_NAME = ConfigKeys.newStringConfigKey("nodejs.app.name", "The name of the NodeJS application");
 
     @SetFromFlag("appCommand")
-    ConfigKey<String> APP_COMMAND = ConfigKeys.newStringConfigKey("nodejs.app.command", "Command to start the NodeJS application", "node");
+    ConfigKey<String> APP_COMMAND = ConfigKeys.newStringConfigKey("nodejs.app.command", "Command to start the NodeJS application (defaults to node)", "node");
+
+    @SetFromFlag("appCommandLine")
+    ConfigKey<String> APP_COMMAND_LINE = ConfigKeys.newStringConfigKey("nodejs.app.commandLine", "Replacement command line to start the NodeJS application (ignores command and file if set)");
 
     @SetFromFlag("nodePackages")
     ConfigKey<List<String>> NODE_PACKAGE_LIST = ConfigKeys.newConfigKey(new TypeToken<List<String>>() { },

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2ce9c528/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
index d9e81b7..24c8581 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
@@ -67,7 +67,7 @@ public class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver impl
     }
 
     protected Map<String, Integer> getPortMap() {
-        return ImmutableMap.of("http", getEntity().getAttribute(WebAppService.HTTP_PORT));
+        return ImmutableMap.of("http", getHttpPort());
     }
 
     @Override
@@ -111,13 +111,13 @@ public class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver impl
         String appName = getEntity().getConfig(NodeJsWebAppService.APP_NAME);
 
         if (Strings.isNonBlank(gitRepoUrl) && Strings.isNonBlank(archiveUrl)) {
-            throw new IllegalStateException("Only one of Git or archive URL must be set");
+            throw new IllegalStateException("Only one of Git or archive URL must be set for " + getEntity());
         } else if (Strings.isNonBlank(gitRepoUrl)) {
             commands.add(String.format("git clone %s %s", gitRepoUrl, appName));
         } else if (Strings.isNonBlank(archiveUrl)) {
             ArchiveUtils.deploy(archiveUrl, getMachine(), getRunDir());
         } else {
-            throw new IllegalStateException("At least one of Git or archive URL must be set");
+            throw new IllegalStateException("At least one of Git or archive URL must be set for " + getEntity());
         }
 
         newScript(CUSTOMIZING)
@@ -132,9 +132,14 @@ public class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver impl
         String appName = getEntity().getConfig(NodeJsWebAppService.APP_NAME);
         String appFile = getEntity().getConfig(NodeJsWebAppService.APP_FILE);
         String appCommand = getEntity().getConfig(NodeJsWebAppService.APP_COMMAND);
+        String appCommandLine = getEntity().getConfig(NodeJsWebAppService.APP_COMMAND_LINE);
+
+        if (Strings.isBlank(appCommandLine)) {
+            appCommandLine = appCommand + " " + appFile;
+        }
 
         commands.add(String.format("cd %s", Os.mergePathsUnix(getRunDir(), appName)));
-        commands.add(BashCommands.sudo("nohup " + appCommand + " " + appFile + " &"));
+        commands.add(BashCommands.sudo("nohup " + appCommandLine + " &"));
 
         newScript(MutableMap.of(USE_PID_FILE, true), LAUNCHING)
                 .body.append(commands)