in src/main/java/org/apache/sling/maven/kickstart/run/LauncherCallable.java [63:136]
public ProcessDescription call() throws Exception {
logger.info("call() started");
// fail if kickstart with this id is already started
if (!ProcessDescriptionProvider.getInstance().isRunConfigurationAvailable(configuration.getId())) {
throw new Exception("Kickstart with id " + configuration.getId() + " is not available");
}
// get the kickstart jar
final File kickstart = this.environment.prepare(this.configuration.getFolder());
// Lock the kickstart id
final String kickstartKey = ProcessDescriptionProvider.getInstance().getId(configuration.getId());
// start kickstart
ProcessDescription cfg = this.start(kickstart);
// Add thread hook to shutdown kickstart
if (environment.isShutdownOnExit()) {
cfg.installShutdownHook();
}
// Add configuration to the config provider
ProcessDescriptionProvider.getInstance().addRunConfiguration(cfg, kickstartKey);
logger.info("Before Check if started");
boolean started = false;
try {
final long endTime = System.currentTimeMillis() + this.environment.getReadyTimeOutSec() * 1000;
boolean finished = false;
while ( !started && !finished && System.currentTimeMillis() < endTime ) {
Thread.sleep(5000);
logger.info("Ask Control Listener: " + cfg.getControlClient());
started = cfg.getControlClient().isStarted();
logger.info("Is Started: " + started);
try {
// if we get an exit value, the process has stopped
cfg.getProcess().exitValue();
finished = true;
} catch ( final IllegalThreadStateException itse) {
// everything as expected
}
}
logger.info("Check Done, started: " + started + ", finihsed: " + finished);
if ( finished ) {
throw new Exception("Kickstart did exit unexpectedly.");
}
if ( !started ) {
throw new Exception("Kickstart did not start successfully in " + this.environment.getReadyTimeOutSec() + " seconds.");
}
// now check for the availability of the HTTP port
boolean httpAvailable = isLocalhostPortAvailable(Integer.valueOf(this.configuration.getPort()));
// repeat until http service is up as well
while ( !httpAvailable && System.currentTimeMillis() < endTime ) {
Thread.sleep(1000);
httpAvailable = isLocalhostPortAvailable(Integer.valueOf(this.configuration.getPort()));
}
if ( !httpAvailable ) {
throw new Exception("Kickstart did not start http service on port " + this.configuration.getPort() + " successfully in " + this.environment.getReadyTimeOutSec() + " seconds.");
}
this.logger.info("Started Kickstart '" + configuration.getId() +
"' at port " + configuration.getPort()+ " [run modes: " + configuration.getRunmode()+ "]");
} finally {
// call kickstart stop routine if not properly started
if (!started) {
stop(this.logger, cfg);
ProcessDescriptionProvider.getInstance().removeRunConfiguration(cfg.getId());
cfg = null;
}
}
return cfg;
}