Search in sources :

Example 1 with StartServerHelper

use of com.sun.enterprise.admin.servermgmt.cli.StartServerHelper in project Payara by payara.

the class StartLocalInstanceCommand method executeCommand.

/**
 */
@Override
protected int executeCommand() throws CommandException {
    if (logger.isLoggable(Level.FINER))
        logger.finer(toString());
    if (sync.equals("none")) {
        logger.info(Strings.get("Instance.nosync"));
    } else {
        if (!synchronizeInstance()) {
            File domainXml = new File(new File(instanceDir, "config"), "domain.xml");
            if (!domainXml.exists()) {
                logger.info(Strings.get("Instance.nodomainxml"));
                return ERROR;
            }
            logger.info(Strings.get("Instance.syncFailed"));
        }
    }
    try {
        // createLauncher needs to go before the helper is created!!
        createLauncher();
        final String mpv = getMasterPassword();
        helper = new StartServerHelper(logger, programOpts.isTerse(), getServerDirs(), launcher, mpv, debug);
        if (!helper.prepareForLaunch()) {
            return ERROR;
        }
        if (dry_run) {
            if (logger.isLoggable(Level.FINE))
                logger.fine(Strings.get("dry_run_msg"));
            List<String> cmd = getLauncher().getCommandLine();
            StringBuilder sb = new StringBuilder();
            for (String s : cmd) {
                sb.append(s);
                sb.append('\n');
            }
            logger.info(sb.toString());
            return SUCCESS;
        }
        getLauncher().launch();
        if (verbose || watchdog) {
            // we can potentially loop forever here...
            while (true) {
                int returnValue = getLauncher().getExitValue();
                switch(returnValue) {
                    case RESTART_NORMAL:
                        logger.info(Strings.get("restart"));
                        break;
                    case RESTART_DEBUG_ON:
                        logger.info(Strings.get("restartChangeDebug", "on"));
                        getInfo().setDebug(true);
                        break;
                    case RESTART_DEBUG_OFF:
                        logger.info(Strings.get("restartChangeDebug", "off"));
                        getInfo().setDebug(false);
                        break;
                    default:
                        return returnValue;
                }
                if (env.debug())
                    System.setProperty(CLIConstants.WALL_CLOCK_START_PROP, "" + System.currentTimeMillis());
                getLauncher().relaunch();
            }
        } else {
            helper.waitForServer();
            helper.report();
            return SUCCESS;
        }
    } catch (GFLauncherException gfle) {
        throw new CommandException(gfle.getMessage());
    } catch (MiniXmlParserException me) {
        throw new CommandException(me);
    }
}
Also used : StartServerHelper(com.sun.enterprise.admin.servermgmt.cli.StartServerHelper) GFLauncherException(com.sun.enterprise.admin.launcher.GFLauncherException) MiniXmlParserException(com.sun.enterprise.universal.xml.MiniXmlParserException)

Aggregations

GFLauncherException (com.sun.enterprise.admin.launcher.GFLauncherException)1 StartServerHelper (com.sun.enterprise.admin.servermgmt.cli.StartServerHelper)1 MiniXmlParserException (com.sun.enterprise.universal.xml.MiniXmlParserException)1