Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The `server` task supports the following operations:

* `create` - creates a named server instance.
* `start` - starts the named server instance in background. If the server instance does not exist, this option creates one by default.
* `startWinService` - starts the named server Windows service.
* `run` - start the named service instance in foreground. If the server instance does not exist, this option creates one by default.
* `stop` - stops the named server.
* `status` - checks the server status.
Expand All @@ -18,14 +19,15 @@ Parameters supported by this task in addition to the [common parameters](common-

| Attribute | Description | Required |
| --------- | ------------ | ----------|
| operation | Server operations available as options: `create`, `start`, `run`, `stop`, `status`, `package`, `dump`, and `javadump`. | Yes |
| operation | Server operations available as options: `create`, `start`, `startWinService`, `run`, `stop`, `status`, `package`, `dump`, and `javadump`. | Yes |
| clean | Clean all cached information on server start up. The default value is `false`. Only used with the `start` operation. | No |
| timeout | Waiting time before the server starts. The default value is 30 seconds. The unit is milliseconds. Only used with the `start` operation. | No |
| include | A comma-delimited list of values. The valid values vary depending on the operation. For the `package` operation the valid values are `all`, `usr`, and `minify`. For the `dump` operation the valid values are `heap`, `system`, and `thread`. For the `javadump` operation the valid values are `heap` and `system`. | Yes, only when the `os` option is set |
| os | A comma-delimited list of operating systems that you want the packaged server to support. Only used with the `package` operation. The 'include' option must be set to 'minify'. | No |
| archive | Location of the target archive file. Only used with the `package` or `dump` operations. | No |
| template | Name of the template to use when creating a new server. Only used with the `create` operation. | No |
| resultProperty | Name of a property in which the server status will be stored. By default the server status will be stored under `wlp.<serverName>.status` property. Only used with the `status` operation. | No |
| serverLogDir | Location of the server log where the message.log file can be found. | No |

#### Examples

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>net.wasdev.wlp.ant</groupId>
<artifactId>wlp-anttasks</artifactId>
<version>1.4-SNAPSHOT</version>
<version>1.3-AM_Patch1</version>
<name>WebSphere Application Server Liberty Profile Ant Tasks</name>
<description>
Parent pom for Ant tasks supporting development with
Expand Down
26 changes: 21 additions & 5 deletions src/main/java/net/wasdev/wlp/ant/AbstractTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,20 @@ public abstract class AbstractTask extends Task {
protected File installDir;
protected File userDir;
protected File outputDir;
protected File serverConfigDir = null;
protected File serverOutputDir = null;
protected File serverLogDir;
protected String serverName;

protected String ref;

protected File serverConfigDir = null;
protected File serverOutputDir = null;

protected static String osName;
protected static boolean isWindows;

protected ProcessBuilder processBuilder;

protected static final String DEFAULT_SERVER = "defaultServer";
protected static final String DEFAULT_LOG_FILE = "logs/messages.log";
protected static final String DEFAULT_LOG_FILE = "messages.log";

protected static final String WLP_USER_DIR_VAR = "WLP_USER_DIR";
protected static final String WLP_OUTPUT_DIR_VAR = "WLP_OUTPUT_DIR";
Expand All @@ -66,6 +67,7 @@ protected void initTask() {
setServerName(((ServerTask) serverRef).getServerName());
setUserDir(((ServerTask) serverRef).getUserDir());
setOutputDir(((ServerTask) serverRef).getOutputDir());
setServerLogDir(((ServerTask) serverRef).getServerLogDir());
}
}

Expand Down Expand Up @@ -122,6 +124,12 @@ protected void initTask() {
}

log(MessageFormat.format(messages.getString("info.variable"), "server.output.dir", serverOutputDir.getCanonicalPath()));

if (serverLogDir == null) {
serverLogDir = new File(serverOutputDir, "logs");
}

log(MessageFormat.format(messages.getString("info.variable"), "server.log.dir", serverLogDir.getCanonicalPath()));
} catch (IOException e) {
throw new BuildException(e);
}
Expand Down Expand Up @@ -156,6 +164,14 @@ public void setOutputDir(File outputDir) {
this.outputDir = outputDir;
}

public File getServerLogDir() {
return serverLogDir;
}

public void setServerLogDir(File serverLogDir) {
this.serverLogDir = serverLogDir;
}

/**
* @return the serverName
*/
Expand All @@ -172,7 +188,7 @@ public void setServerName(String serverName) {
}

public File getLogFile() {
return new File(serverOutputDir, DEFAULT_LOG_FILE);
return new File(serverLogDir, DEFAULT_LOG_FILE);
}

/**
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/net/wasdev/wlp/ant/ServerTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public void execute() {
doRun();
} else if ("start".equals(operation)) {
doStart();
} else if ("startWinService".equals(operation)) {
doStartWinService();
} else if ("stop".equals(operation)) {
doStop();
} else if ("status".equals(operation)) {
Expand Down Expand Up @@ -141,6 +143,21 @@ private void doStart() throws Exception {
}
validateServerStarted(getLogFile(), startTimeout);
}

private void doStartWinService() throws Exception {
List<String> command = getInitialCommand(operation);
addCleanOption(command);
processBuilder.command(command);
Process p = processBuilder.start();
checkReturnCode(p, processBuilder.command().toString(), ReturnCode.OK.getValue(), ReturnCode.REDUNDANT_ACTION_STATUS.getValue());

// check server started message code.
long startTimeout = SERVER_START_TIMEOUT_DEFAULT;
if (timeout != null && !timeout.equals("")) {
startTimeout = Long.valueOf(timeout);
}
validateServerStarted(getLogFile(), startTimeout);
}

private void validateServerStarted(File outputFile, long startTimeout) throws Exception {

Expand Down