Guest User

Untitled

a guest
May 20th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.42 KB | None | 0 0
  1.     public void startLongRunningCommand(InfrastructureNode infrastructureNode, String command) throws Exception {
  2.         RemoteLongRunningWrapperBean remoteLongRunningWrapperBean = null;
  3.         try {
  4.             remoteLongRunningWrapperBean = stageLongRunningScript(infrastructureNode);
  5.         } catch (IOException ie) {
  6.             log.error("Staging the longRunWrapper script failed!", ie);
  7.         }
  8.         SshCmdOutput sshCmdOutput = null;
  9.         try {
  10.             if (!doesFileExist(infrastructureNode, remoteLongRunningWrapperBean.getFullRemotePath())) {
  11.                 log.error("The remote long running script does not exist!");
  12.                 throw new IOException();
  13.             } //"nohup echo hi > foo.out 2> foo.err < /dev/null &"
  14.             final String fullCmd = "nohup " + remoteLongRunningWrapperBean.getFullRemotePath() + " \"" + command + "\" > "
  15.                     + Long.toString(remoteLongRunningWrapperBean.getIdentifier()) + "-stdout 2> "
  16.                     + Long.toString(remoteLongRunningWrapperBean.getIdentifier()) + "-stderr< /dev/null &";
  17.             sshCmdOutput = runSshCommand(infrastructureNode, fullCmd);
  18.             log.info(sshCmdOutput.getStdoutString());
  19.             log.info(sshCmdOutput.getStdoutString());
  20.         } catch (Exception ie) {
  21.             log.error("Unable to run the remote long run wrapper, something is not good here...", ie);
  22.             throw ie;
  23.         }
  24.     }
Add Comment
Please, Sign In to add comment