| | |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.backends.RootDSEBackend; |
| | | import static org.opends.server.config.ConfigConstants.DN_MONITOR_ROOT; |
| | | import static org.opends.server.config.ConfigConstants.ENV_VAR_INSTANCE_ROOT; |
| | | import static org.opends.server.config.ConfigConstants.ENV_VAR_INSTALL_ROOT; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.config.JMXMBean; |
| | |
| | | |
| | | // If a server.starting file exists, then remove it. |
| | | File serverStartingFile = |
| | | new File(configHandler.getServerRoot() + File.separator + |
| | | new File(configHandler.getInstanceRoot() + File.separator + |
| | | "logs" + File.separator + "server.starting"); |
| | | if (serverStartingFile.exists()) |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the path to the instance directory for this instance of the |
| | | * Directory Server. |
| | | * |
| | | * @return The path to the instance directory for this instance of |
| | | * the Directory Server. |
| | | */ |
| | | public static String getInstanceRoot() |
| | | { |
| | | if (directoryServer.configHandler == null) |
| | | { |
| | | File serverRoot = directoryServer.environmentConfig.getServerRoot(); |
| | | if (serverRoot != null) |
| | | { |
| | | File instanceRoot = |
| | | directoryServer.environmentConfig.getInstanceRootFromServerRoot( |
| | | serverRoot); |
| | | if (instanceRoot != null) |
| | | { |
| | | return instanceRoot.getAbsolutePath(); |
| | | } |
| | | } |
| | | |
| | | // We don't know where the server root is, so we'll have to assume it's |
| | | // the current working directory. |
| | | return System.getProperty("user.dir"); |
| | | } |
| | | else |
| | | { |
| | | return directoryServer.configHandler.getInstanceRoot(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the time that the Directory Server was started, in milliseconds |
| | | * since the epoch. |
| | | * |
| | |
| | | { |
| | | String pidFilePath; |
| | | String startingFilePath; |
| | | String serverRoot = System.getenv(ENV_VAR_INSTANCE_ROOT); |
| | | if (serverRoot == null) |
| | | String serverRoot = System.getenv(ENV_VAR_INSTALL_ROOT); |
| | | File instanceRoot = DirectoryEnvironmentConfig |
| | | .getInstanceRootFromServerRoot(new File(serverRoot)); |
| | | if (instanceRoot == 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"; |
| | | pidFilePath = instanceRoot.getAbsolutePath() + File.separator + "logs" |
| | | + File.separator + "server.pid"; |
| | | startingFilePath = instanceRoot.getAbsolutePath() + File.separator |
| | | + "logs" + File.separator + "server.starting"; |
| | | } |
| | | |
| | | File pidFile = new File(pidFilePath); |
| | |
| | | // We need to figure out where to put the file. See if the server root |
| | | // is available as an environment variable and if so then use it. |
| | | // Otherwise, try to figure it out from the location of the config file. |
| | | String serverRoot = System.getenv(ENV_VAR_INSTANCE_ROOT); |
| | | String serverRoot = System.getenv(ENV_VAR_INSTALL_ROOT); |
| | | if (serverRoot == null) |
| | | { |
| | | serverRoot = new File(configFile.getValue()).getParentFile(). |
| | |
| | | } |
| | | else |
| | | { |
| | | File logDir = new File(serverRoot + File.separator + "logs"); |
| | | File instanceRoot = DirectoryEnvironmentConfig |
| | | .getInstanceRootFromServerRoot(new File(serverRoot)); |
| | | File logDir = new File(instanceRoot.getAbsolutePath() + File.separator |
| | | + "logs"); |
| | | if (logDir.exists()) |
| | | { |
| | | FileOutputStream fos = |