|
@@ -14,20 +14,18 @@ public class ShellUtil {
|
|
|
public final static String LAS_TO_BIN = "bash /home/ubuntu/bin/PotreeConverter.sh @inPath @outPath ''";
|
|
|
|
|
|
|
|
|
- public static void execDockerCmd(String cmd,String filePath){
|
|
|
+ public static void execDockerCmd(String cmd){
|
|
|
log.info("execDockerCmd:{}",cmd);
|
|
|
- ProcessBuilder processBuilder = new ProcessBuilder(cmd);
|
|
|
- processBuilder.directory(new File(filePath));
|
|
|
Process process;
|
|
|
try {
|
|
|
- process = processBuilder.start();
|
|
|
- BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
|
|
- String line;
|
|
|
- System.out.println("Output is: ");
|
|
|
- while ((line = br.readLine()) != null) {
|
|
|
- System.out.println(line);
|
|
|
- }
|
|
|
+ process = Runtime.getRuntime().exec(cmd);
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
+ // 获取命令执行结果, 有两个结果: 正常的输出 和 错误的输出(PS: 子进程的输出就是主进程的输入)
|
|
|
+ //处理InputStream的线程
|
|
|
+ threadRun(process);
|
|
|
+ // 方法阻塞, 等待命令执行完成(成功会返回0)
|
|
|
process.waitFor();
|
|
|
+ log.info("execDockerCmd:{},耗时:{}", cmd,System.currentTimeMillis() -startTime);
|
|
|
} catch (Exception e) {
|
|
|
log.error("execDockerCmd:{},error:{}",cmd,e);
|
|
|
}
|