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

jvergara
18.15.2010 c7ddc18873a3cde7b866cb399faefed2dc9b44b4
Fix for issue 4381 (Enabling windows service once server started fails to detect server status)
If the server is running, launch the service after the service has been enabled. The code of the service (native code in service.c) already handles the case where the server is running before the service code has been launched.
2 files modified
40 ■■■■ changed files
opendj-sdk/opends/src/messages/messages/tools.properties 5 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/tools/ConfigureWindowsService.java 35 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/messages/messages/tools.properties
@@ -20,7 +20,7 @@
#
# CDDL HEADER END
#
#      Copyright 2006-2009 Sun Microsystems, Inc.
#      Copyright 2006-2010 Sun Microsystems, Inc.
@@ -2552,3 +2552,6 @@
 the period (in seconds) between two displays of the status
INFO_INSTALLDS_PRINT_EQUIVALENT_COMMAND_LINE_1708=Print equivalent \
 non-interactive command-line
MILD_ERR_WINDOWS_SERVICE_ENABLING_ERROR_STARTING_SERVER_1709=The Windows \
 Service was successfully configured but there was an error starting it.  \
 Error code starting Windows Service: %d.
opendj-sdk/opends/src/server/org/opends/server/tools/ConfigureWindowsService.java
@@ -22,10 +22,11 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 */
package org.opends.server.tools;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.Message;
import java.io.BufferedReader;
@@ -462,13 +463,39 @@
    try
    {
      boolean isServerRunning = Utilities.isServerRunning(
          new File(serverRoot));
      int resultCode = Runtime.getRuntime().exec(cmd).waitFor();
      switch (resultCode)
      {
      case 0:
        returnValue = SERVICE_ENABLE_SUCCESS;
        msg = INFO_WINDOWS_SERVICE_SUCCESSULLY_ENABLED.get();
        out.println(wrapText(msg, MAX_LINE_WIDTH));
        if (isServerRunning)
        {
          // We have to launch the windows service.  The service code already
          // handles this case (the service binary is executed when the server
          // already runs).
          returnValue = StartWindowsService.startWindowsService(out, err);
          if (returnValue == 0)
          {
            returnValue = SERVICE_ENABLE_SUCCESS;
            msg = INFO_WINDOWS_SERVICE_SUCCESSULLY_ENABLED.get();
            out.println(wrapText(msg, MAX_LINE_WIDTH));
          }
          else
          {
            msg = ERR_WINDOWS_SERVICE_ENABLING_ERROR_STARTING_SERVER.get(
                returnValue);
            returnValue = SERVICE_ENABLE_ERROR;
            err.println(wrapText(msg, MAX_LINE_WIDTH));
          }
        }
        else
        {
          returnValue = SERVICE_ENABLE_SUCCESS;
          msg = INFO_WINDOWS_SERVICE_SUCCESSULLY_ENABLED.get();
          out.println(wrapText(msg, MAX_LINE_WIDTH));
        }
        break;
      case 1:
        returnValue = SERVICE_ALREADY_ENABLED;