コード例 #1
0
  /*
   * Load using arguments
   */
  public void load(String args[]) {

    try {
      if (arguments(args)) load();
    } catch (Exception e) {
      e.printStackTrace(System.out);
    }
  }
コード例 #2
0
ファイル: Catalina.java プロジェクト: glorydom321/MyTomcat
  /** Start a new server instance. */
  public void start() {

    if (getServer() == null) {
      load();
    }

    if (getServer() == null) {
      log.fatal("Cannot start server. Server instance is not configured.");
      return;
    }

    long t1 = System.nanoTime();

    // Start the new server
    try {
      getServer().start();
    } catch (LifecycleException e) {
      log.fatal(sm.getString("catalina.serverStartFail"), e);
      try {
        getServer().destroy();
      } catch (LifecycleException e1) {
        log.debug("destroy() failed for failed Server ", e1);
      }
      return;
    }

    long t2 = System.nanoTime();
    if (log.isInfoEnabled()) {
      log.info("Server startup in " + ((t2 - t1) / 1000000) + " ms");
    }

    // Register shutdown hook
    if (useShutdownHook) {
      if (shutdownHook == null) {
        shutdownHook = new CatalinaShutdownHook();
      }
      Runtime.getRuntime().addShutdownHook(shutdownHook);

      // If JULI is being used, disable JULI's shutdown hook since
      // shutdown hooks run in parallel and log messages may be lost
      // if JULI's hook completes before the CatalinaShutdownHook()
      LogManager logManager = LogManager.getLogManager();
      if (logManager instanceof ClassLoaderLogManager) {
        ((ClassLoaderLogManager) logManager).setUseShutdownHook(false);
      }
    }

    if (await) {
      await();
      stop();
    }
  }
コード例 #3
0
  /** Start a new server instance. */
  public void start() {

    if (getServer() == null) {
      load();
    }

    if (getServer() == null) {
      log.fatal("Cannot start server. Server instance is not configured.");
      return;
    }

    long t1 = System.nanoTime();

    // Start the new server
    if (getServer() instanceof Lifecycle) {
      try {
        ((Lifecycle) getServer()).start();
      } catch (LifecycleException e) {
        log.error("Catalina.start: ", e);
      }
    }

    long t2 = System.nanoTime();
    if (log.isInfoEnabled()) log.info("Server startup in " + ((t2 - t1) / 1000000) + " ms");

    try {
      // Register shutdown hook
      if (useShutdownHook) {
        if (shutdownHook == null) {
          shutdownHook = new CatalinaShutdownHook();
        }
        Runtime.getRuntime().addShutdownHook(shutdownHook);

        // If JULI is being used, disable JULI's shutdown hook since
        // shutdown hooks run in parallel and log messages may be lost
        // if JULI's hook completes before the CatalinaShutdownHook()
        LogManager logManager = LogManager.getLogManager();
        if (logManager instanceof ClassLoaderLogManager) {
          ((ClassLoaderLogManager) logManager).setUseShutdownHook(false);
        }
      }
    } catch (Throwable t) {
      // This will fail on JDK 1.2. Ignoring, as Tomcat can run
      // fine without the shutdown hook.
    }

    if (await) {
      await();
      stop();
    }
  }
コード例 #4
0
  /**
   * The instance main program.
   *
   * @param args Command line arguments
   */
  public void process(String args[]) {

    setAwait(true);
    setCatalinaHome();
    setCatalinaBase();
    try {
      if (arguments(args)) {
        if (starting) {
          load(args);
          start();
        } else if (stopping) {
          stopServer();
        }
      }
    } catch (Exception e) {
      e.printStackTrace(System.out);
    }
  }