use of org.commonjava.propulsor.deploy.DeployException in project indy by Commonjava.
the class IndyDeployer method deploy.
@Override
public void deploy(BootOptions bootOptions) throws DeployException {
final DeploymentInfo di = indyDeployment.getDeployment(bootOptions.getContextPath()).setContextPath("/");
final DeploymentManager dm = Servlets.defaultContainer().addDeployment(di);
Collection<String> list = Servlets.defaultContainer().listDeployments();
logger.info("List deployments: {}", list);
dm.deploy();
try {
Integer port = bootOptions.getPort();
if (port < 1) {
logger.info("Looking for open Undertow port...");
final AtomicReference<Exception> errorHolder = new AtomicReference<>();
final AtomicReference<Integer> usingPort = new AtomicReference<>();
server = PortFinder.findPortFor(16, (foundPort) -> {
usingPort.set(foundPort);
try {
return buildAndStartUndertow(dm, foundPort, bootOptions.getBind(), restConfig);
} catch (Exception e) {
errorHolder.set(e);
}
return null;
});
Exception e = errorHolder.get();
if (e != null) {
throw e;
}
bootOptions.setPort(usingPort.get());
} else {
logger.info("Start Undertow server, bind: {}, port: {}", bootOptions.getBind(), port);
server = buildAndStartUndertow(dm, port, bootOptions.getBind(), restConfig);
}
logger.info("Indy listening on {}:{}\n\n", bootOptions.getBind(), bootOptions.getPort());
} catch (Exception e) {
logger.error("Deploy failed", e);
throw new DeployException("Deploy failed", e);
}
}
Aggregations