long start = System.currentTimeMillis();
if (log.isDebugEnabled()) {
log.debug("About to execute the following process: [" + processExecution + "]");
}
ProcessExecutionResults results = this.systemInfo.executeProcess(processExecution);
logExecutionResults(results);
Throwable error = results.getError();
Integer exitCode = results.getExitCode();
AvailabilityType avail;
if (startScriptFailed(controlMethod, error, exitCode, isWindows())) {
String output = results.getCapturedOutput();
String message = "Script returned error or non-zero exit code while starting the Tomcat instance - exitCode=["
+ ((exitCode != null) ? exitCode : "UNKNOWN") + "], output=[" + output + "].";
if (error == null) {
log.error(message);
} else {
log.error(message, error);
}
avail = this.serverComponent.getAvailability();
} else {
avail = waitForServerToStart(start);
}
// If, after the loop, the Server is still down, consider the start to be a failure.
if (avail == AvailabilityType.DOWN) {
throw new RuntimeException("Server failed to start: " + results.getCapturedOutput());
} else {
return "Server has been started.";
}
}