public static void main(String[] args) {
    if (args.length == 0 || args.length > 6) {
      System.err.println(
          "Usage: port [bind-address] [peerLocator] [serverLocator] [hostname-for-clients]");
      System.err
          .println("A zero-length address will bind to localhost");
      System.err.println(
          "A zero-length gemfire-properties-file will mean use the default search path");
      System.err.println(
          "peerLocator and serverLocator both default to true");
      System.err.println(
          "A zero-length hostname-for-clients will default to bind-address");
      ExitCode.FATAL.doSystemExit();
    } else {
      shutdown = false;
    }
    SystemFailure.loadEmergencyClasses();

    final int port = parsePort(args[0]);
    HostAddress hostAddress = null;
    String hostnameForClients = null;
    try {
      if (args.length > 1 && !args[1].equals("")) {
        if (!SystemAdmin.validLocalAddress(args[1])) {
          System.err.println(
              String.format("'%s' is not a valid IP address for this machine",
                  args[1]));
          ExitCode.FATAL.doSystemExit();
        }
        hostAddress = new HostAddress(args[1]);
        // do a look-up to ensure that the name can be resolved to an address
        InetAddress.getByName(args[1]);
      } else {
        // address = null; // was InetAddress.getLocalHost(); (redundant assignment)
      }
      if (args.length > 4) {
        hostnameForClients = args[4];
      }

      final InetAddress inetAddress = hostAddress == null ? null : hostAddress.getAddress();
      if (!Boolean.getBoolean(InternalDistributedSystem.DISABLE_SHUTDOWN_HOOK_PROPERTY)) {
        Runtime.getRuntime()
            .addShutdownHook(new LoggingThread("LocatorShutdownThread", false, () -> {
              try {
                DistributionLocator.shutdown(port, inetAddress);
              } catch (IOException e) {
                e.printStackTrace();
              }
            }));
      }

      lockFile = ManagerInfo.setLocatorStarting(directory, port, inetAddress);
      lockFile.deleteOnExit();

      InetAddress address = hostAddress == null ? null : hostAddress.getAddress();
      try {
        InternalLocator locator = InternalLocator.startLocator(port, new File(DEFAULT_LOG_FILE),
            null, null, hostAddress, true, null, hostnameForClients);
        ManagerInfo.setLocatorStarted(directory, port, address);
        locator.waitToStop();
      } finally {
        shutdown(port, address);
      }

    } catch (InterruptedException ex) {
      // We were interrupted while waiting for the locator to stop.
      // No big deal.

    } catch (java.net.BindException ex) {
      logger.fatal("Could not bind locator to {}[{}]",
          new Object[] {hostAddress, port});
      ExitCode.FATAL.doSystemExit();

    } catch (Exception ex) {
      logger.fatal("Could not start locator",
          ex);
      ExitCode.FATAL.doSystemExit();
    }
  }
Cleans up the artifacts left by this managed locator VM.
geode-core/src/main/java/org/apache/geode/internal/DistributionLocator.java