From 3af39927fd1bba93a2769cd5d6bc7b6c5f924c64 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Sun, 02 Sep 2007 01:12:13 +0000
Subject: [PATCH] Update the server so that it has the ability to save a copy of its current configuration into a ".startok" file whenever it starts successfully. The start-ds script and DirectoryEnvironmentConfig class have been updated to expose an option to try to start the server using this "last known good" configuration rather than the active config file.
---
opends/src/server/org/opends/server/core/DirectoryServer.java | 71 +++++++++++++++++++++++++++++++----
1 files changed, 62 insertions(+), 9 deletions(-)
diff --git a/opends/src/server/org/opends/server/core/DirectoryServer.java b/opends/src/server/org/opends/server/core/DirectoryServer.java
index 028bad1..c5efb40 100644
--- a/opends/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -359,6 +359,10 @@
// been abandoned.
private boolean notifyAbandonedOperations;
+ // Indicates whether to save a copy of the configuration on successful
+ // startup.
+ private boolean saveConfigOnSuccessfulStartup;
+
// Indicates whether the server is currently in the process of shutting down.
private boolean shuttingDown;
@@ -1428,6 +1432,14 @@
}
+ // If we should write a copy of the config on successful startup, then do
+ // so now.
+ if (saveConfigOnSuccessfulStartup)
+ {
+ configHandler.writeSuccessfulStartupConfig();
+ }
+
+
// Mark the current time as the start time and indicate that the server is
// now running.
startUpTime = System.currentTimeMillis();
@@ -7727,6 +7739,37 @@
/**
+ * Indicates whether the Directory Server should save a copy of its
+ * configuration whenever it is started successfully.
+ *
+ * @return {@code true} if the server should save a copy of its configuration
+ * whenever it is started successfully, or {@code false} if not.
+ */
+ public static boolean saveConfigOnSuccessfulStartup()
+ {
+ return directoryServer.saveConfigOnSuccessfulStartup;
+ }
+
+
+
+ /**
+ * Specifies whether the Directory Server should save a copy of its
+ * configuration whenever it is started successfully.
+ *
+ * @param saveConfigOnSuccessfulStartup Specifies whether the server should
+ * save a copy of its configuration
+ * whenever it is started successfully.
+ */
+ public static void setSaveConfigOnSuccessfulStartup(
+ boolean saveConfigOnSuccessfulStartup)
+ {
+ directoryServer.saveConfigOnSuccessfulStartup =
+ saveConfigOnSuccessfulStartup;
+ }
+
+
+
+ /**
* Registers the provided backup task listener with the Directory Server.
*
* @param listener The backup task listener to register with the Directory
@@ -8999,15 +9042,16 @@
public static void main(String[] args)
{
// Define the arguments that may be provided to the server.
- BooleanArgument checkStartability = null;
- BooleanArgument quietMode = null;
- BooleanArgument windowsNetStart = null;
- BooleanArgument displayUsage = null;
- BooleanArgument fullVersion = null;
- BooleanArgument noDetach = null;
- BooleanArgument systemInfo = null;
- StringArgument configClass = null;
- StringArgument configFile = null;
+ BooleanArgument checkStartability = null;
+ BooleanArgument quietMode = null;
+ BooleanArgument windowsNetStart = null;
+ BooleanArgument displayUsage = null;
+ BooleanArgument fullVersion = null;
+ BooleanArgument noDetach = null;
+ BooleanArgument systemInfo = null;
+ BooleanArgument useLastKnownGoodConfig = null;
+ StringArgument configClass = null;
+ StringArgument configFile = null;
// Create the command-line argument parser for use with this program.
@@ -9064,6 +9108,13 @@
argParser.addArgument(systemInfo);
+ useLastKnownGoodConfig =
+ new BooleanArgument("lastknowngoodconfig", 'L',
+ "useLastKnownGoodConfig",
+ INFO_DSCORE_DESCRIPTION_LASTKNOWNGOODCFG.get());
+ argParser.addArgument(useLastKnownGoodConfig);
+
+
noDetach = new BooleanArgument("nodetach", 'N', "nodetach",
INFO_DSCORE_DESCRIPTION_NODETACH.get());
argParser.addArgument(noDetach);
@@ -9389,6 +9440,8 @@
configClass.getValue());
environmentConfig.setProperty(PROPERTY_CONFIG_FILE,
configFile.getValue());
+ environmentConfig.setProperty(PROPERTY_USE_LAST_KNOWN_GOOD_CONFIG,
+ String.valueOf(useLastKnownGoodConfig.isPresent()));
startupErrorLogPublisher =
--
Gitblit v1.10.0