@Nullable CliResult lockOrActivate(@NotNull Path currentDirectory, @NotNull List<String> args) throws CannotActivateException, IOException {
    var configDir = NioFiles.createDirectories(myLockFile.getParent());
    var systemDir = NioFiles.createDirectories(myPortFile.getParent());
    if (Files.isSameFile(systemDir, configDir)) {
      throw new IllegalArgumentException(BootstrapBundle.message("bootstrap.error.same.directories"));
    }

    try {
      return tryListen();
    }
    catch (BindException | FileAlreadyExistsException e) {
      LOG.debug(e);
    }

    try {
      return tryConnect(args, currentDirectory);
    }
    catch (SocketException e) {
      LOG.debug(e);
    }
    catch (IOException e) {
      LOG.debug(e);
      throw new CannotActivateException(e);
    }

    if (LOG.isDebugEnabled()) LOG.debug("deleting " + myPortFile);
    Files.deleteIfExists(myPortFile);
    if (myRedirectedPortFile != null) {
      if (LOG.isDebugEnabled()) LOG.debug("deleting " + myRedirectedPortFile);
      Files.deleteIfExists(myRedirectedPortFile);
    }

    return tryListen();
  }
@Nullable CliResult lockOrActivate(@NotNull Path currentDirectory, @NotNull List<String> args)