use of org.wildfly.core.launcher.StandaloneCommandBuilder in project wildfly-maven-plugin by wildfly.
the class StartMojo method createStandaloneCommandBuilder.
private CommandBuilder createStandaloneCommandBuilder(final Path jbossHome) throws MojoExecutionException {
final StandaloneCommandBuilder commandBuilder = StandaloneCommandBuilder.of(jbossHome).setJavaHome(javaHome).addModuleDirs(modulesPath.getModulePaths());
// Set the JVM options
if (Utils.isNotNullOrEmpty(javaOpts)) {
commandBuilder.setJavaOptions(javaOpts);
}
if (serverConfig != null) {
commandBuilder.setServerConfiguration(serverConfig);
}
if (propertiesFile != null) {
commandBuilder.setPropertiesFile(propertiesFile);
}
if (serverArgs != null) {
commandBuilder.addServerArguments(serverArgs);
}
final Path javaHomePath = (this.javaHome == null ? Paths.get(System.getProperty("java.home")) : Paths.get(this.javaHome));
if (Environment.isModularJvm(javaHomePath)) {
commandBuilder.addJavaOptions(Environment.getModularJvmArguments());
}
// Print some server information
final Log log = getLog();
log.info("JAVA_HOME : " + commandBuilder.getJavaHome());
log.info("JBOSS_HOME: " + commandBuilder.getWildFlyHome());
log.info("JAVA_OPTS : " + Utils.toString(commandBuilder.getJavaOptions(), " "));
try {
addUsers(commandBuilder.getWildFlyHome(), commandBuilder.getJavaHome());
} catch (IOException e) {
throw new MojoExecutionException("Failed to add users", e);
}
return commandBuilder;
}
use of org.wildfly.core.launcher.StandaloneCommandBuilder in project wildfly-maven-plugin by wildfly.
the class StandaloneDeploymentManagerIT method startServer.
@BeforeClass
public static void startServer() throws Exception {
boolean ok = false;
try {
client = Environment.createClient();
if (ServerHelper.isDomainRunning(client) || ServerHelper.isStandaloneRunning(client)) {
Assert.fail("A WildFly server is already running: " + ServerHelper.getContainerDescription(client));
}
final StandaloneCommandBuilder commandBuilder = StandaloneCommandBuilder.of(Environment.WILDFLY_HOME);
process = Launcher.of(commandBuilder).launch();
consoleConsomer = ConsoleConsumer.start(process, System.out);
ServerHelper.waitForStandalone(client, Environment.TIMEOUT);
ok = true;
} finally {
if (!ok) {
final Process p = process;
final ModelControllerClient c = client;
process = null;
client = null;
try {
ProcessHelper.destroyProcess(p);
} finally {
safeClose(c);
}
}
}
}
use of org.wildfly.core.launcher.StandaloneCommandBuilder in project wildfly-maven-plugin by wildfly.
the class StandaloneTestServer method start.
@Override
public void start() {
if (STARTED.compareAndSet(false, true)) {
try {
final StandaloneCommandBuilder commandBuilder = StandaloneCommandBuilder.of(TestEnvironment.WILDFLY_HOME).setBindAddressHint("management", TestEnvironment.HOSTNAME).addJavaOption("-Djboss.management.http.port=" + TestEnvironment.PORT);
final Process process = Launcher.of(commandBuilder).setRedirectErrorStream(true).launch();
consoleConsumer = ConsoleConsumer.start(process, System.out);
shutdownThread = ProcessHelper.addShutdownHook(process);
client = ModelControllerClient.Factory.create(TestEnvironment.HOSTNAME, TestEnvironment.PORT);
currentProcess = process;
ServerHelper.waitForStandalone(process, client, TestEnvironment.TIMEOUT);
deploymentManager = DeploymentManager.Factory.create(client);
} catch (Throwable t) {
try {
throw new RuntimeException("Failed to start server", t);
} finally {
STARTED.set(false);
cleanUp();
}
}
}
}
Aggregations