当前位置: 首页>>代码示例>>Java>>正文


Java ProcessExecutor.start方法代码示例

本文整理汇总了Java中org.zeroturnaround.exec.ProcessExecutor.start方法的典型用法代码示例。如果您正苦于以下问题:Java ProcessExecutor.start方法的具体用法?Java ProcessExecutor.start怎么用?Java ProcessExecutor.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.zeroturnaround.exec.ProcessExecutor的用法示例。


在下文中一共展示了ProcessExecutor.start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDataIsFlushedToProcessWithANonEndingInputStream

import org.zeroturnaround.exec.ProcessExecutor; //导入方法依赖的package包/类
@Test
 public void testDataIsFlushedToProcessWithANonEndingInputStream() throws Exception {
String str = "Tere Minu Uus vihik " + System.nanoTime();

// Setup InputStream that will block on a read()
   PipedOutputStream pos = new PipedOutputStream();
   PipedInputStream pis = new PipedInputStream(pos);
   ByteArrayOutputStream baos = new ByteArrayOutputStream();

   ProcessExecutor exec = new ProcessExecutor("java", "-cp", "target/test-classes", PrintInputToOutput.class.getName());
   exec.redirectInput(pis).redirectOutput(baos);
   StartedProcess startedProcess = exec.start();
   pos.write(str.getBytes());
   pos.write("\n\n\n".getBytes()); // PrintInputToOutput processes at most 3 lines
   
   // Assert that we don't get a TimeoutException
   startedProcess.getFuture().get(5, TimeUnit.SECONDS);
   Assert.assertEquals(str, baos.toString());
 }
 
开发者ID:zeroturnaround,项目名称:zt-exec,代码行数:20,代码来源:ProcessExecutorInputStreamTest.java

示例2: frontendStart

import org.zeroturnaround.exec.ProcessExecutor; //导入方法依赖的package包/类
private void frontendStart() throws IOException {
	ProcessExecutor processExecutor = new ProcessExecutor()
			.directory(new File("frontend"))
			.command("yarn", "start")
			.redirectOutput(Slf4jStream.of(LoggerFactory.getLogger("yarn")).asInfo())
			.redirectError(Slf4jStream.of(LoggerFactory.getLogger("yarn")).asError());

	if (isWindows()) {
		processExecutor = processExecutor.command("cmd", "/c", "yarn", "start");
	}

	processExecutor.start();
}
 
开发者ID:UniteGG,项目名称:gamelocker-status,代码行数:14,代码来源:FrontendRunner.java

示例3: yarnStart

import org.zeroturnaround.exec.ProcessExecutor; //导入方法依赖的package包/类
private void yarnStart(File frontendDir) throws IOException {
  ProcessExecutor process = command("yarn", "start")
    .directory(frontendDir)
    .redirectOutput(Slf4jStream.of(LoggerFactory.getLogger("yarn")).asInfo())
    .redirectError(Slf4jStream.of(LoggerFactory.getLogger("yarn")).asError());

  process.start();
}
 
开发者ID:wlindner,项目名称:ReBoot,代码行数:9,代码来源:YarnRunner.java

示例4: call

import org.zeroturnaround.exec.ProcessExecutor; //导入方法依赖的package包/类
@Override
public StartedProcess call() throws RabbitMqCommandException {

  List<String> fullCommand = new ArrayList<>(arguments);
  fullCommand.add(0, executableFile.toString());

  Slf4jStream loggingStream = Slf4jStream.of(processOutputLogger);
  LoggingProcessListener loggingListener = new LoggingProcessListener(processOutputLogger);

  ProcessExecutor processExecutor = processExecutorFactory.createInstance()
      .environment(config.getEnvVars())
      .directory(config.getAppFolder())
      .command(fullCommand)
      .destroyOnExit()
      .addListener(loggingListener)               // Logs process events (like start, stop...)
      .addListener(eventsListener)                // Notifies asynchronously of process events (start/finish/stop)
      .redirectError(loggingStream.as(stdErrLogLevel))     // Logging for output made to STDERR
      .redirectOutput(loggingStream.as(stdOutLogLevel))     // Logging for output made to STDOUT
      .redirectOutputAlsoTo(outputStream)         // Pipe stdout to this stream for the application to process
      .redirectErrorAlsoTo(errorOutputStream)     // Pipe stderr to this stream for the application to process
      .readOutput(storeOutput);                   // Store the output in the ProcessResult as well.

  try {
    return processExecutor.start();
  } catch (IOException e) {
    throw new RabbitMqCommandException("Failed to execute: " + StringUtils.join(fullCommand, " "), e);
  }
}
 
开发者ID:AlejandroRivera,项目名称:embedded-rabbitmq,代码行数:29,代码来源:RabbitMqCommand.java

示例5: testRedirectPipedInputStream

import org.zeroturnaround.exec.ProcessExecutor; //导入方法依赖的package包/类
@Test
public void testRedirectPipedInputStream() throws Exception {
  // Setup InputStream that will block on a read()
  PipedOutputStream pos = new PipedOutputStream();
  PipedInputStream pis = new PipedInputStream(pos);
  ByteArrayOutputStream baos = new ByteArrayOutputStream();

  ProcessExecutor exec = new ProcessExecutor("java", "-cp", "target/test-classes", PrintArguments.class.getName());
  exec.redirectInput(pis);
  StartedProcess startedProcess = exec.start();
  // Assert that we don't get a TimeoutException
  startedProcess.getFuture().get(5, TimeUnit.SECONDS);
}
 
开发者ID:zeroturnaround,项目名称:zt-exec,代码行数:14,代码来源:ProcessExecutorInputStreamTest.java

示例6: startProcess

import org.zeroturnaround.exec.ProcessExecutor; //导入方法依赖的package包/类
private StartedProcess startProcess() throws IOException {
    ProcessExecutor processExecutor = buildProcessExecutor();
    return processExecutor.start();
}
 
开发者ID:svenkubiak,项目名称:mangooio,代码行数:5,代码来源:Runner.java


注:本文中的org.zeroturnaround.exec.ProcessExecutor.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。