public static InternalLocator startLocator(int port, File logFile, InternalLogWriter logWriter,
      InternalLogWriter securityLogWriter,
      HostAddress bindAddress,
      boolean startDistributedSystem,
      Properties distributedSystemProperties,
      String hostnameForClients, Path workingDirectory)
      throws IOException {
    System.setProperty(FORCE_LOCATOR_DM_TYPE, "true");
    InternalLocator newLocator = null;

    boolean startedLocator = false;
    try {

      // if startDistributedSystem is true then Locator uses a NullLoggingSession (does nothing)
      LoggingSession loggingSession =
          startDistributedSystem ? NullLoggingSession.create() : LoggingSession.create();

      newLocator = createLocator(port, loggingSession, logFile, logWriter, securityLogWriter,
          bindAddress, hostnameForClients, distributedSystemProperties,
          workingDirectory);

      loggingSession.createSession(newLocator);
      loggingSession.startSession();

      try {
        newLocator.startPeerLocation();

        if (startDistributedSystem) {

          try {
            newLocator.startDistributedSystem();
          } catch (RuntimeException e) {
            newLocator.stop();
            throw e;
          }

          InternalDistributedSystem system = newLocator.internalDistributedSystem;
          if (system != null) {
            system.getDistributionManager().addHostedLocators(system.getDistributedMember(),
                getLocatorStrings(), newLocator.isSharedConfigurationEnabled());
          }
        }
      } catch (IllegalStateException e) {
        newLocator.stop();
        throw e;
      }

      InternalDistributedSystem system = InternalDistributedSystem.getConnectedInstance();
      if (system != null) {
        try {
          newLocator.startServerLocation(system);
        } catch (RuntimeException e) {
          newLocator.stop();
          throw e;
        }
      }

      newLocator.endStartLocator(null);
      startedLocator = true;
      return newLocator;

    } finally {
      System.clearProperty(FORCE_LOCATOR_DM_TYPE);

      if (!startedLocator) {
        removeLocator(newLocator);
      }
    }
  }
Creates a distribution locator that runs in this VM on the given port and bind address in the
specified working directory.

<p>
This is for internal use only as it does not create a distributed system unless told to do so.

@param port the tcp/ip port to listen on
@param logFile the file that log messages should be written to
@param logWriter a log writer that should be used (logFile parameter is ignored)
@param securityLogWriter the logWriter to be used for security related log messages
@param bindAddress the bind address for the locator
@param startDistributedSystem if true, a distributed system is started
@param distributedSystemProperties optional properties to configure the distributed system
       (e.g., mcast
       addr/port, other locators)
@param hostnameForClients the name to give to clients for connecting to this locator
@param workingDirectory the working directory to use for any files
geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java