import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.sonar.process.ProcessId;
import org.sonar.process.command.AbstractCommand;
import org.sonar.process.command.EsCommand;
import org.sonar.process.command.JavaCommand;
import org.sonar.process.sharedmemoryfile.AllProcessesCommands;
import org.sonar.process.sharedmemoryfile.ProcessCommands;
-import org.sonar.process.ProcessId;
import static java.lang.String.format;
import static org.sonar.process.ProcessEntryPoint.PROPERTY_PROCESS_INDEX;
try {
writeConfFiles(esCommand);
ProcessBuilder processBuilder = create(esCommand);
- if (LOG.isInfoEnabled()) {
- LOG.info("Launch process[{}]: {}", processId.getKey(), String.join(" ", processBuilder.command()));
- }
+ logLaunchedCommand(esCommand, processBuilder);
process = processBuilder.start();
ProcessCommands commands = allProcessesCommands.createAfterClean(processId.getIpcIndex());
ProcessBuilder processBuilder = create(javaCommand);
- if (LOG.isInfoEnabled()) {
- LOG.info("Launch process[{}]: {}", processId.getKey(), String.join(" ", processBuilder.command()));
- }
+ logLaunchedCommand(javaCommand, processBuilder);
process = processBuilder.start();
return new ProcessCommandsProcessMonitor(process, processId, commands);
} catch (Exception e) {
}
}
+ private static <T extends AbstractCommand> void logLaunchedCommand(AbstractCommand<T> command, ProcessBuilder processBuilder) {
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Launch process[{}] from [{}]: {}",
+ command.getProcessId(),
+ command.getWorkDir().getAbsolutePath(),
+ String.join(" ", processBuilder.command()));
+ }
+ }
+
private ProcessBuilder create(EsCommand esCommand) {
List<String> commands = new ArrayList<>();
commands.add(esCommand.getExecutable().getAbsolutePath());