Add javaOptions to Deployable.

Example command:
```
spring cloud -d configserver -- --logging.level.org.springframework.cloud.launcher.deployer=DEBUG --spring.cloud.launcher.deployables.configserver.java-options=-Dmy.system.prop=myval,-Dmy.system.prop2=yourval
```

fixes gh-18
This commit is contained in:
Spencer Gibb
2016-09-12 15:20:48 -06:00
parent 2dc5b47ac4
commit af4e68719f
3 changed files with 28 additions and 7 deletions

View File

@@ -31,7 +31,7 @@
<properties>
<spring-cloud-dataflow.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-dataflow.version>
<spring-cloud-deployer.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-deployer.version>
<spring-cloud-deployer.version>1.0.3.BUILD-SNAPSHOT</spring-cloud-deployer.version>
</properties>
<dependencyManagement>

View File

@@ -138,10 +138,15 @@ public class DeployerProperties {
*/
private String message;
/**
* A map of"negative" properties that apply to all apps when this one is disabled.
* A map of "negative" properties that apply to all apps when this one is disabled.
* E.g. when eureka is disabled you might want "eureka.client.enabled=false".
*/
private Map<String, String> disabled = new LinkedHashMap<>();
/**
* A list of java options to pass to the jvm command (e.g. java).
* E.g. -Dmy.prop=myval
*/
private List<String> javaOptions = new ArrayList<>();
public String getCoordinates() {
return this.coordinates;
@@ -200,6 +205,14 @@ public class DeployerProperties {
return disabled;
}
public List<String> getJavaOptions() {
return javaOptions;
}
public void setJavaOptions(List<String> javaOptions) {
this.javaOptions = javaOptions;
}
@Override
public String toString() {
final StringBuffer sb = new StringBuffer("Deployable{");
@@ -209,6 +222,7 @@ public class DeployerProperties {
sb.append(", waitUntilStarted=").append(this.waitUntilStarted);
sb.append(", order=").append(this.order);
sb.append(", disabled=").append(this.disabled);
sb.append(", javaOptions=").append(this.javaOptions);
sb.append(", message=").append(this.message);
sb.append('}');
return sb.toString();

View File

@@ -20,7 +20,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@@ -54,6 +53,8 @@ import org.springframework.core.io.ResourceLoader;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import static org.springframework.util.StringUtils.collectionToCommaDelimitedString;
/**
* @author Spencer Gibb
*/
@@ -271,14 +272,20 @@ public class DeployerThread extends Thread {
AppDefinition definition = new AppDefinition(deployable.getName(), appDefProps);
Map<String, String> environmentProperties = Collections
.singletonMap(AppDeployer.GROUP_PROPERTY_KEY, "launcher");
Map<String, String> deploymentProperties = new LinkedHashMap<>();
deploymentProperties.put(AppDeployer.GROUP_PROPERTY_KEY, "launcher");
if (deployable.getJavaOptions() != null && !deployable.getJavaOptions().isEmpty()) {
deploymentProperties.put("JAVA_OPTS", collectionToCommaDelimitedString(deployable.getJavaOptions()));
}
AppDeploymentRequest request = new AppDeploymentRequest(definition, resource,
environmentProperties);
deploymentProperties);
logger.debug("Deploying resource {} = {}", deployable.getName(),
deployable.getCoordinates());
logger.debug("Properties: {}", appDefProps);
logger.debug("AppDefinition Properties: {}", appDefProps);
logger.debug("Deployment Properties: {}", deploymentProperties);
String id = deployer.deploy(request);
AppStatus appStatus = getAppStatus(deployer, id);
// TODO: stream stdout/stderr like docker-compose (with colors and prefix)