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

jvergara
07.01.2008 bc67703dbdca616d9a6a34b25382ec417bd8c22e
Fix for issues:

3238: On Windows, start-ds closes the Command Prompt window at exit
3240: Cannot revert after upgrade

Use an environment variable to return the exit code in start-ds.bat without the parameter /B. By default it returns with the /B option so that the command prompt window is not closed.

Appart from that update start-ds.bat so that we explicitly exit an error code.
2 files modified
35 ■■■■ changed files
opends/resource/bin/start-ds.bat 26 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java 9 ●●●● patch | view | raw | blame | history
opends/resource/bin/start-ds.bat
@@ -41,7 +41,9 @@
rem Set environment variables
set SCRIPT_UTIL_CMD=set-full-environment-and-test-java
call "%INSTANCE_ROOT%\lib\_script-util.bat"
if NOT %errorlevel% == 0 exit %errorlevel%
set ERROR_CODE=%errorlevel%
if NOT %ERROR_CODE% == 0 goto exitErrorCode
echo %SCRIPT%: CLASSPATH=%CLASSPATH% >> %LOG%
@@ -58,11 +60,13 @@
if %errorlevel% == 102 goto runDetachCalledByWinService
if %errorlevel% == 103 goto runDetachQuiet
if %errorlevel% == 104 goto runNoDetachQuiet
goto end
set ERROR_CODE=%errorlevel%
goto exitErrorCode
:serverAlreadyStarted
echo %SCRIPT%: Server already started  >> %LOG%
goto end
set ERROR_CODE=0
goto exitErrorCode
:runNoDetach
echo %SCRIPT%: Run no detach  >> %LOG%
@@ -70,7 +74,8 @@
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" %*
goto end
set ERROR_CODE=%errorlevel%
goto exitErrorCode
:runNoDetachQuiet
echo %SCRIPT%: Run no detach  >> %LOG%
@@ -78,8 +83,8 @@
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
set ERROR_CODE=%errorlevel%
goto exitErrorCode
:runDetach
echo %SCRIPT%: Run detach  >> %LOG%
@@ -132,12 +137,17 @@
:serverStarted
echo %SCRIPT%: finished >> %LOG%
exit 0
set ERROR_CODE=0
goto exitErrorCode
:serverNotStarted
echo %SCRIPT%: finished >> %LOG%
exit 1
set ERROR_CODE=1
goto exitErrorCode
:exitErrorCode
if "%OPENDS_EXIT_NO_BACKGROUND%" == "true" exit %ERROR_CODE%
exit /B %ERROR_CODE%
:end
echo %SCRIPT%: finished >> %LOG%
opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
@@ -81,6 +81,8 @@
    try {
      Map<String, String> env = pb.environment();
      env.put(SetupUtils.OPENDS_JAVA_HOME, System.getProperty("java.home"));
      // This is required in order the return code to be valid.
      env.put("OPENDS_EXIT_NO_BACKGROUND", "true");
      final Process process = pb.start();
      is = process.getInputStream();
      out = process.getOutputStream();
@@ -98,8 +100,11 @@
              try
              {
                Thread.sleep(5000);
                fOut.write(Constants.LINE_SEPARATOR.getBytes());
                fOut.flush();
                if (!done[0])
                {
                  fOut.write(Constants.LINE_SEPARATOR.getBytes());
                  fOut.flush();
                }
              }
              catch (Throwable t)
              {