public ManagedProcess launch(AbstractCommand command) {
    EsInstallation esInstallation = command.getEsInstallation();
    if (esInstallation != null) {
      cleanupOutdatedEsData(esInstallation);
      writeConfFiles(esInstallation);
    }

    Process process;
    if (command instanceof JavaCommand<?> javaCommand) {
      process = launchJava(javaCommand);
    } else {
      throw new IllegalStateException("Unexpected type of command: " + command.getClass());
    }

    ProcessId processId = command.getProcessId();
    try {
      if (processId == ProcessId.ELASTICSEARCH) {
        checkArgument(esInstallation != null, "Incorrect configuration EsInstallation is null");
        EsConnectorImpl esConnector = new EsConnectorImpl(singleton(HostAndPort.fromParts(esInstallation.getHost(),
          esInstallation.getHttpPort())), esInstallation.getBootstrapPassword(), esInstallation.getHttpKeyStoreLocation(),
          esInstallation.getHttpKeyStorePassword().orElse(null));
        return new EsManagedProcess(process, processId, esConnector);
      } else {
        ProcessCommands commands = allProcessesCommands.createAfterClean(processId.getIpcIndex());
        return new ProcessCommandsManagedProcess(process, processId, commands);
      }
    } catch (Exception e) {
      // just in case
      if (process != null) {
        process.destroyForcibly();
      }
      throw new IllegalStateException(format("Fail to launch monitor of process [%s]", processId.getHumanReadableName()), e);
    }
  }
@Test
  public void temporary_properties_file_can_be_avoided() throws Exception {
    File tempDir = temp.newFolder();
    TestProcessBuilder processBuilder = new TestProcessBuilder();
    ProcessLauncher underTest = new ProcessLauncherImpl(tempDir, commands, () -> processBuilder);
    JavaCommand<JvmOptions<?>> command = new JavaCommand<>(ProcessId.WEB_SERVER, temp.newFolder());
    command.setReadsArgumentsFromFile(false);
    command.setArgument("foo", "bar");
    command.setArgument("baz", "woo");
    command.setJvmOptions(new JvmOptions<>());

    underTest.launch(command);

    String propsFilePath = processBuilder.commands.get(processBuilder.commands.size() - 1);
    File file = new File(propsFilePath);
    assertThat(file).doesNotExist();
  }