コード例 #1
0
  /**
   * Exec the server process, notify mProcessWaitForThread (so that it will notice when the process
   * dies) and enable the heartbeat thread.
   */
  protected void startExecution() {
    customStartup();

    if (mGeneration > 0 && mIsJavaServer) {
      try {
        prepare();
      } catch (Exception ex) {
        mLogger.severe("Improper configuration for server", ex);
        synchronized (this) {
          mDisabled = true;
          changeState(STATE_DISABLED);
        }
        return;
      }
    }

    try {
      String runSeparator =
          "-------------------- Generation " + (mGeneration + 1) + " --------------------";

      mLogger.finest(runSeparator);
      mLogger.finest(LogUtil.splitLine(mPrintableCommand));
      mProcess = Runtime.getRuntime().exec(mPrintableCommand);
      new GetPidThread("server." + getName() + ".getpid").start();
      mExecTime = System.currentTimeMillis();
      mGeneration++;
      updateServerStatus();

      mLogger.finer("Spawned process");

      if (isNativeLoggingUsed()) {
        mStderr.setStream(mProcess.getErrorStream());
        mStdout.setStream(mProcess.getInputStream());
      }

      // Wake up the thread that waits for a process to die
      synchronized (mProcessWaitForThread) {
        mProcessWaitForThread.notifyAll();
      }
    } catch (IOException ioe) {
      mLogger.severe("Failure in starting server; Generation : mGeneration", ioe);
      synchronized (this) {
        mDisabled = true;
        changeState(STATE_DISABLED);
      }
    }
  }
コード例 #2
0
 /** @param name This server's name. */
 public ProcessExecutor(String name) {
   super(name);
   mServerStatus.setMonitor(false);
   mProcessWaitForThread = new ProcessWaitForThread(name);
   mProcessWaitForThread.start();
 }