code: public void watchShutdown(int stoppingTimeout, int shutdownTimeout)
              throws Exception {
  
          if (!_statusFile.exists()) {
              _statusFile
                      .append(ServerState.STOPPING,
                              "WARNING: Server status file did not exist; re-created");
          }
  
          // use this for timeout checks later
          long startTime = System.currentTimeMillis();
  
          ServerStatusMessage[] messages = getAllMessages();
  
          ServerStatusMessage lastMessage = messages[messages.length - 1];
  
          boolean stopping = false;
          boolean stopped = false;
          while (!stopped) {
  
              showShutdown(messages);
  
              // update stopping and stopped flags, and
              // throw a shutdown exception if STOPPED_WITH_ERR
              // is encountered
              for (ServerStatusMessage element : messages) {
                  ServerState state = element.getState();
                  if (state == ServerState.STOPPING) {
                      stopping = true;
                  } else if (state == ServerState.STOPPED) {
                      stopped = true;
                  } else if (state == ServerState.STOPPED_WITH_ERR) {
                      throw new Exception("Fedora shutdown finished with error (see above)");
                  }
              }
  
              if (!stopped) {
  
                  // wait half a second
                  try {
                      Thread.sleep(500);
                  } catch (Throwable th) {
                  }
  
                  // throw an exception if either timeout has been
                  // exceeded
                  long now = System.currentTimeMillis();
                  if (!stopping) {
                      if ((now - startTime) / 1000 > stoppingTimeout) {
                          throw new Exception("Server shutdown did not begin within "
                                  + stoppingTimeout + " seconds");
                      }
                  }
                  if ((now - startTime) / 1000 > shutdownTimeout) {
                      throw new Exception("Server shutdown did not complete within "
                              + shutdownTimeout + " seconds");
                  }
  
                  // get next batch of messages
                  messages = _statusFile.getMessages(lastMessage);
                  if (messages.length > 0) {
                      lastMessage = messages[messages.length - 1];
                  }
              }
  
          }
  
      }
docs: Watch the status file and print details to standard output until the
  STOPPED or STOPPED_WITH_ERR state is encountered. If there are any
  problems reading the status file, a timeout is reached, or
  STOPPED_WITH_ERR is encountered, this will throw an exception.