예제 #1
0
  /**
   * Starts commands and blocks current thread until all processes are in state {@link
   * State#STARTED}.
   *
   * @throws java.lang.IllegalArgumentException if commands list is empty
   * @throws java.lang.IllegalStateException if already started or if at least one process failed to
   *     start. In this case all processes are terminated. No need to execute {@link #stop()}
   */
  public void start(List<JavaCommand> commands) {
    if (commands.isEmpty()) {
      throw new IllegalArgumentException("At least one command is required");
    }

    if (lifecycle.getState() != State.INIT) {
      throw new IllegalStateException("Can not start multiple times");
    }

    // intercepts CTRL-C
    Runtime.getRuntime().addShutdownHook(shutdownHook);

    // start watching for restart requested by child process
    restartWatcher.start();

    javaCommands = commands;
    startProcesses();
  }
예제 #2
0
 public State getState() {
   return lifecycle.getState();
 }