mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

neil_a_wilson
31.14.2006 c323bf3f3ab24ab3cb4957ac3f9f5c1c8ac79cb3
Update the DirectoryServer class so that the server.pid and server.starting
files will be marked for deletion as soon as possible. This will help the
start-ds script to exit more quickly in the event that the provided set of
command-line arguments was invalid, as well as the case in which a valid set of
arguments was provided but the server should not actually be started (e.g.,
"--version").

OpenDS Issue Number: 906
1 files modified
47 ■■■■■ changed files
opends/src/server/org/opends/server/core/DirectoryServer.java 47 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -7418,6 +7418,43 @@
   */
  public static void main(String[] args)
  {
    // Configure the JVM to delete the PID file on exit, if it exists.
    boolean pidFileMarkedForDeletion      = false;
    boolean startingFileMarkedForDeletion = false;
    try
    {
      String pidFilePath;
      String startingFilePath;
      String serverRoot = System.getenv(ENV_VAR_INSTANCE_ROOT);
      if (serverRoot == null)
      {
        pidFilePath      = "logs/server.pid";
        startingFilePath = "logs/server.starting";
      }
      else
      {
        pidFilePath      = serverRoot + File.separator + "logs" +
                           File.separator + "server.pid";
        startingFilePath = serverRoot + File.separator + "logs" +
                           File.separator + "server.starting";
      }
      File pidFile = new File(pidFilePath);
      if (pidFile.exists())
      {
        pidFile.deleteOnExit();
        pidFileMarkedForDeletion = true;
      }
      File startingFile = new File(startingFilePath);
      if (startingFile.exists())
      {
        startingFile.deleteOnExit();
        startingFileMarkedForDeletion = true;
      }
    } catch (Exception e) {}
    // Define the arguments that may be provided to the server.
    BooleanArgument displayUsage = null;
    BooleanArgument dumpMessages = null;
@@ -7607,7 +7644,7 @@
    // Redirect standard output and standard error to the server.out file.  If
    // the server hasn't detached from the terminal, then also continue writing
    // to the original standard output and standard error.  Also, configure the
    // JVM to delete the PID file on exit, if it exists.
    // JVM to delete the PID and server.starting files on exit, if they exist.
    PrintStream serverOutStream;
    try
    {
@@ -7646,18 +7683,24 @@
          System.setOut(serverOutStream);
          System.setErr(serverOutStream);
          if (! pidFileMarkedForDeletion)
          {
          File f = new File(logDir, "server.pid");
          if (f.exists())
          {
            f.deleteOnExit();
          }
          }
          f = new File(logDir, "server.starting");
          if (! startingFileMarkedForDeletion)
          {
            File f = new File(logDir, "server.starting");
          if (f.exists())
          {
            f.deleteOnExit();
          }
        }
        }
        else
        {
          System.err.println("WARNING:  Unable to redirect standard output " +