Search in sources :

Example 11 with ProcessManager

use of com.sun.enterprise.universal.process.ProcessManager in project Payara by payara.

the class NucleusTestUtils method cmdWithOutput.

public static NadminReturn cmdWithOutput(final File cmd, final int timeout, final String... args) {
    List<String> command = new ArrayList<String>();
    command.add(cmd.toString());
    command.add("--echo");
    command.addAll(Arrays.asList(args));
    ProcessManager pm = new ProcessManager(command);
    // the tests may be running unattended -- don't wait forever!
    pm.setTimeoutMsec(timeout);
    pm.setEcho(false);
    pm.setEnvironment(envp);
    int exit;
    String myErr = "";
    try {
        exit = pm.execute();
    } catch (ProcessManagerTimeoutException tex) {
        myErr = "\nProcessManagerTimeoutException: command timed out after " + timeout + " ms.";
        exit = 1;
    } catch (ProcessManagerException ex) {
        ex.printStackTrace();
        myErr = "\n" + ex.getMessage();
        exit = 1;
    }
    NadminReturn ret = new NadminReturn(exit, pm.getStdout(), pm.getStderr() + myErr, args[0]);
    write(ret.outAndErr);
    return ret;
}
Also used : ProcessManagerTimeoutException(com.sun.enterprise.universal.process.ProcessManagerTimeoutException) ProcessManagerException(com.sun.enterprise.universal.process.ProcessManagerException) ArrayList(java.util.ArrayList) ProcessManager(com.sun.enterprise.universal.process.ProcessManager)

Example 12 with ProcessManager

use of com.sun.enterprise.universal.process.ProcessManager in project Payara by payara.

the class WindowsService method install.

private void install() throws ProcessManagerException {
    if (info.dryRun) {
        try {
            // dry-run not so useful on Windows.  Very useful on UNIX...
            xmlFileCopy = Strings.get("xmlfiledump") + FileUtils.readSmallFile(targetXml);
        } catch (IOException ex) {
        // oh well....
        }
        if (!targetWin32Exe.delete())
            dryRun("Dry Run error: delete failed for targetWin32Exe " + targetWin32Exe);
        if (!targetXml.delete())
            dryRun("Dry Run error: delete failed for targetXml " + targetXml);
    } else {
        ProcessManager mgr = new ProcessManager(targetWin32Exe.getPath(), "install");
        mgr.setEcho(false);
        mgr.execute();
        int ret = mgr.getExitValue();
        if (ret != 0)
            throw new RuntimeException(Strings.get("windows.services.install.bad", "" + ret, mgr.getStdout(), mgr.getStderr()));
        trace("Install STDERR: " + mgr.getStderr());
        trace("Install STDOUT: " + mgr.getStdout());
    }
}
Also used : ProcessManager(com.sun.enterprise.universal.process.ProcessManager)

Example 13 with ProcessManager

use of com.sun.enterprise.universal.process.ProcessManager in project Payara by payara.

the class SetupLocalDcom method executeCommand.

@Override
protected int executeCommand() throws CommandException, CommandValidationException {
    try {
        List<String> cmds = new ArrayList<String>();
        cmds.add(CPP_APP.getAbsolutePath());
        if (verbose)
            cmds.add("--verbose");
        ProcessManager pm = new ProcessManager(cmds);
        pm.execute();
        int ret = pm.getExitValue();
        if (verbose || ret != 0)
            logger.info(pm.getStdout() + pm.getStderr());
        return ret;
    } catch (ProcessManagerException ex) {
        throw new CommandException(ex);
    }
}
Also used : ProcessManagerException(com.sun.enterprise.universal.process.ProcessManagerException) ProcessManager(com.sun.enterprise.universal.process.ProcessManager)

Aggregations

ProcessManager (com.sun.enterprise.universal.process.ProcessManager)13 ProcessManagerException (com.sun.enterprise.universal.process.ProcessManagerException)10 ArrayList (java.util.ArrayList)4 ProcessManagerTimeoutException (com.sun.enterprise.universal.process.ProcessManagerTimeoutException)2 File (java.io.File)2 IOException (java.io.IOException)1 KeyStore (java.security.KeyStore)1