コード例 #1
0
ファイル: FileSystemOpBase.java プロジェクト: vadeq/repotest
  public void execute() throws Exception {
    getNewCount();
    File executable = new File(getEXEPath());
    if (!executable.exists())
      throw new FileNotFoundException("executable file does not exist! " + executable);
    workingDir = getWorkingDirectory(executable);
    initExecution();

    instruction = getInstructionFileName(workingDir);
    output = getOutputFileName(workingDir);
    createInstructionFile(instruction);
    // Profiler pofiler = new Profiler();
    // profiler.start("exec-ilink-search " + xmlFileName, "exec-ilink-search " + xmlFileName);
    ExecShell shell = new ExecShell();
    shell.setExecutable(executable.getAbsolutePath());
    shell.setWorkingDirectory(workingDir);
    setArguments(shell);
    shell.addCommandLineArgument(executable.getParent());
    shell.execute();

    // profiler.start("exec-ilink-search " + xmlFileName, "shell-wait-for");
    exitCode = shell.timeout(timeout);
    // profiler.stop("exec-ilink-search " + xmlFileName, "shell-wait-for");
    // instructionFile.delete();
    handleResponse(output);
    finishExecution();
    if (zws.Server.debugMode()) return;
    // cleanup
    File[] contents = workingDir.listFiles();
    for (int idx = 0; idx < contents.length; contents[idx++].delete()) ;
    workingDir.delete();
  }
コード例 #2
0
ファイル: PrinterSvc.java プロジェクト: vadeq/repotest
 public static synchronized void printPS(Origin o, String printerAlias, int copyCount)
     throws Exception {
   String command = Properties.get(Names.PS_PRINT_APP);
   Printer printer = find(printerAlias);
   File printTemp =
       new File(
           Properties.get(Names.TEMP_DIR) + Names.PATH_SEPARATOR + "print-queue",
           "print-" + getNextCount());
   if (printTemp.exists()) FileUtil.delete(printTemp);
   printTemp.mkdirs();
   InputStream in = Downloader.download(o);
   File print = new File(printTemp, o.getName());
   if (print.exists()) print.delete();
   FileUtil.save(in, print, true);
   File work =
       new File(
           Properties.get(Names.WORKING_DIR) + Names.PATH_SEPARATOR + "print",
           "work-" + getNextCount());
   if (!work.exists()) work.mkdirs();
   int i;
   for (i = 0; i < copyCount; i++) {
     ExecShell shell = new ExecShell();
     shell.setExecutable(command);
     shell.setWorkingDirectory(work);
     shell.addCommandLineArgument("/D:" + printer.getPath(), false);
     shell.addCommandLineArgument(print.getAbsolutePath(), true);
     {
     } // Logwriter.printOnConsole("sleeping for 2..");
     Thread.sleep(2000);
     {
     } // Logwriter.printOnConsole("waking up");
     shell.execute();
   }
 }
コード例 #3
0
ファイル: HTTPUptimeMonitor.java プロジェクト: vadeq/repotest
  private static void restartServer(int err) {
    String subject = "Restarting Server: " + remoteHost + " [" + err + "]!!";
    String message = "Description of last Response:" + Names.NEW_LINE;
    message += "URL: " + url + Names.NEW_LINE;
    message += "Response: " + HTTPCodes[err] + "[" + err + "]" + Names.NEW_LINE;
    message += "Attempting to restart server: " + remoteHost + Names.NEW_LINE;
    try {
      EMail.send(FROM, mailTo, subject, message, smtpHost);
    } catch (Exception e) {
      e.printStackTrace();
    }

    {
    } // System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    {
    } // System.out.println("Attempting restart server: " + remoteHost);
    ExecShell down = new ExecShell();
    down.setExecutable(downCommand);
    down.addCommandLineArgument(remoteHost, false);
    try {
      {
      } // System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
      {
      } // System.out.println("Bringing server down on " + remoteHost + " with " + downCommand);
      down.execute();
      down.waitFor();
      Sleep.sleep(SERVER_SHUTDOWN_DURATION * 1000);
    } catch (Exception e) {
      subject = "ERROR Restarting Server on " + remoteHost;
      message = "Could not execute bring down command: " + downCommand + Names.NEW_LINE;
      try {
        EMail.send(FROM, mailTo, subject, message, smtpHost);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
      {
      } // System.out.println("Could not execute bring down command: " + downCommand);
      {
      } // System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    }

    ExecShell up = new ExecShell();
    up.setExecutable(upCommand);
    up.addCommandLineArgument(remoteHost, false);
    try {
      {
      } // System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
      {
      } // System.out.println("Bringing server up on " + remoteHost + " with " + upCommand);
      up.execute();
      up.waitFor();
      Sleep.sleep(SERVER_STARTUP_DURATION * 1000);
      int code = getResponseCode();
      if (code > 199 && code < 206) {
        subject = "Server is back up: " + remoteHost + "[" + code + "].";
        message = "Http Response=" + HTTPCodes[code] + "[" + code + "] for " + url;
        {
        } // System.out.println(subject);
        {
        } // System.out.println(message);
        try {
          EMail.send(FROM, mailTo, subject, message, smtpHost);
        } catch (Exception ex) {
          ex.printStackTrace();
        }
      } else {
        subject = "Could not bring server back up" + " [" + code + "]!";
        message = "Http Response=" + HTTPCodes[code] + "[" + code + "] for " + url;
        {
        } // System.out.println(subject);
        {
        } // System.out.println(message);
        EMail.send(FROM, mailTo, subject, message, smtpHost);
      }
      {
      } // System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    } catch (Exception e) {
      subject = "ERROR Restarting Server on " + remoteHost;
      message = "Could not execute bring up command: " + upCommand;
      {
      } // System.out.println(subject);
      {
      } // System.out.println(message);
      {
      } // System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
      try {
        EMail.send(FROM, mailTo, subject, message, smtpHost);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
  }
コード例 #4
0
ファイル: FileSystemOpBase.java プロジェクト: vadeq/repotest
 protected void setArguments(ExecShell shell) {
   shell.addCommandLineArgument(instruction);
   shell.addCommandLineArgument(output);
 }