From c323bf3f3ab24ab3cb4957ac3f9f5c1c8ac79cb3 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Tue, 31 Oct 2006 00:14:36 +0000
Subject: [PATCH] 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/src/server/org/opends/server/core/DirectoryServer.java | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 50 insertions(+), 7 deletions(-)
diff --git a/opends/src/server/org/opends/server/core/DirectoryServer.java b/opends/src/server/org/opends/server/core/DirectoryServer.java
index 25ac8f5..94e6740 100644
--- a/opends/src/server/org/opends/server/core/DirectoryServer.java
+++ b/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,16 +7683,22 @@
System.setOut(serverOutStream);
System.setErr(serverOutStream);
- File f = new File(logDir, "server.pid");
- if (f.exists())
+ if (! pidFileMarkedForDeletion)
{
- f.deleteOnExit();
+ File f = new File(logDir, "server.pid");
+ if (f.exists())
+ {
+ f.deleteOnExit();
+ }
}
- f = new File(logDir, "server.starting");
- if (f.exists())
+ if (! startingFileMarkedForDeletion)
{
- f.deleteOnExit();
+ File f = new File(logDir, "server.starting");
+ if (f.exists())
+ {
+ f.deleteOnExit();
+ }
}
}
else
--
Gitblit v1.10.0