private void command(
ExecutionMonitor monitor,
ExecutionContext context,
ExecutionScript script,
List<String> command) throws InterruptedException, IOException {
assert monitor != null;
assert context != null;
assert command != null;
assert command.isEmpty() == false;
Map<String, String> env = getEnvironmentVariables(context, script);
LOG.debug("env: {}", env);
LOG.debug("command: {}", command);
Map<String, Blob> extensions = BlobUtil.getExtensions(context, script);
LOG.debug("extensions: {}", extensions);
monitor.checkCancelled();
ProcessExecutor executor = getCommandExecutor();
int exit = executor.execute(context, command, env, extensions, monitor.getOutput());
if (exit == 0) {
return;
}
throw new ExitCodeException(MessageFormat.format(
"Unexpected exit code from command job: "
+ "code={4} (batch={0}, flow={1}, phase={2}, exection={3})",
context.getBatchId(),
context.getFlowId(),
context.getPhase(),
context.getExecutionId(),
String.valueOf(exit)), exit);
}