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

jvergara
07.16.2008 6d3f56fc888974eacd0645805e3dead753e255f3
Fix for issue 3237 (On Windows, start-ds -Q doesn't start the server)

There are a couple of issues here:

1. The start-ds.bat file must be updated to handle correctly the -Q option.
2. The start-ds shell file must be updated to handle correctly the nodetach and quiet options together.
3 files modified
52 ■■■■■ changed files
opends/resource/bin/start-ds 11 ●●●●● patch | view | raw | blame | history
opends/resource/bin/start-ds.bat 20 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/DirectoryServer.java 21 ●●●● patch | view | raw | blame | history
opends/resource/bin/start-ds
@@ -121,6 +121,17 @@
      org.opends.server.core.DirectoryServer \
      --configClass org.opends.server.extensions.ConfigFileHandler \
      --configFile "${CONFIG_FILE}" "${@}"
  elif test ${EC} -eq 104
  then
    #
    # run no detach quiet
    #
    echo $$ > "${PID_FILE}"
    rm -f "${LOG_FILE}"
    exec "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
      org.opends.server.core.DirectoryServer \
      --configClass org.opends.server.extensions.ConfigFileHandler \
      --configFile "${CONFIG_FILE}" "${@}" > /dev/null
  else
    #
    # an error or the server is already started.  Just return the code provided
opends/resource/bin/start-ds.bat
@@ -56,6 +56,8 @@
if %errorlevel% == 100 goto runNoDetach
if %errorlevel% == 101 goto runAsService
if %errorlevel% == 102 goto runDetachCalledByWinService
if %errorlevel% == 103 goto runDetachQuiet
if %errorlevel% == 104 goto runNoDetachQuiet
goto end
:serverAlreadyStarted
@@ -70,6 +72,14 @@
"%OPENDS_JAVA_BIN%" %OPENDS_SERVER_JAVA_ARGS% %SCRIPT_NAME_ARG% org.opends.server.core.DirectoryServer --configClass org.opends.server.extensions.ConfigFileHandler --configFile "%DIR_HOME%\config\config.ldif" %*
goto end
:runNoDetachQuiet
echo %SCRIPT%: Run no detach  >> %LOG%
if not exist "%DIR_HOME%\logs\server.out" echo. > "%DIR_HOME%\logs\server.out"
if not exist "%DIR_HOME%\logs\server.starting" echo. > "%DIR_HOME%\logs\server.starting"
if exist "%DIR_HOME%\lib\set-java-args.bat %SCRIPT%" DO call "%DIR_HOME%\lib\set-java-args.bat"
"%OPENDS_JAVA_BIN%" %OPENDS_SERVER_JAVA_ARGS% %SCRIPT_NAME_ARG% org.opends.server.core.DirectoryServer --configClass org.opends.server.extensions.ConfigFileHandler --configFile "%DIR_HOME%\config\config.ldif" %* >> %LOG%
goto end
:runDetach
echo %SCRIPT%: Run detach  >> %LOG%
@@ -81,6 +91,16 @@
"%OPENDS_JAVA_BIN%" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete --targetFile "%DIR_HOME%\logs\server.starting" --logFile "%DIR_HOME%\logs\server.out"
goto checkStarted
:runDetachQuiet
echo %SCRIPT%: Run detach  >> %LOG%
if not exist "%DIR_HOME%\logs\server.out" echo. > "%DIR_HOME%\logs\server.out"
if not exist "%DIR_HOME%\logs\server.starting" echo. > "%DIR_HOME%\logs\server.starting"
if exist "%DIR_HOME%\lib\set-java-args.bat" DO call "%DIR_HOME%\lib\set-java-args.bat"
"%DIR_HOME%\lib\winlauncher.exe" start "%DIR_HOME%" "%OPENDS_JAVA_BIN%" %OPENDS_SERVER_JAVA_ARGS%  %SCRIPT_NAME_ARG% org.opends.server.core.DirectoryServer --configClass org.opends.server.extensions.ConfigFileHandler --configFile "%DIR_HOME%\config\config.ldif" %*
echo %SCRIPT%: Waiting for "%DIR_HOME%\logs\server.out" to be deleted >> %LOG%
"%OPENDS_JAVA_BIN%" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete --targetFile "%DIR_HOME%\logs\server.starting" --logFile "%DIR_HOME%\logs\server.out" >> %LOG%
goto checkStarted
:runDetachCalledByWinService
rem We write the output of the start command to the winservice.out file.
echo %SCRIPT%: Run detach called by windows service  >> %LOG%
opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -273,6 +273,11 @@
   * output.
   */
  private static int START_AS_DETACH_QUIET = 103;
  /**
   * The server must be started as non-detached process and should not produce
   * any output.
   */
  private static int START_AS_NON_DETACH_QUIET = 104;
  // The policy to use regarding single structural objectclass enforcement.
  private AcceptRejectWarn singleStructuralClassPolicy;
@@ -1172,7 +1177,7 @@
                  String.valueOf(configClass),
                  String.valueOf(configFile),
                  e.getLocalizedMessage());
      throw new InitializationException(message);
      throw new InitializationException(message, e);
    }
  }
@@ -9284,8 +9289,9 @@
      //   intended command.  If that command was successful, then we'll have an
      //   exit code of NOTHING_TO_DO (0).  Otherwise, it will have an exit code
      //   that is something other than NOTHING_TO_DO, SERVER_ALREADY_STARTED,
      //   START_AS_DETACH, START_AS_NON_DETACH, START_AS_WINDOWS_SERVICE to
      //   indicate that a problem occurred.
      //   START_AS_DETACH, START_AS_NON_DETACH, START_AS_WINDOWS_SERVICE,
      //   START_AS_DETACH_QUIET, START_AS_NON_DETACH_QUIET to indicate that a
      //   problem occurred.
      if (argParser.usageOrVersionDisplayed())
      {
        // We're just trying to display usage, and that's already been done so
@@ -9740,7 +9746,14 @@
      {
        if (noDetachPresent)
        {
          returnValue = START_AS_NON_DETACH;
          if (quietMode.isPresent())
          {
            returnValue = START_AS_NON_DETACH_QUIET;
          }
          else
          {
            returnValue = START_AS_NON_DETACH;
          }
        }
        else if (quietMode.isPresent())
        {