target/classes/org/apache/catalina/startup/Bootstrap.java
/**
     * Main method and entry point when starting Tomcat via the provided
     * scripts.
     *
     * @param args Command line arguments to be processed
     */
Main method and entry point when starting Tomcat via the provided
scripts.

@param args Command line arguments to be processed
Main method and entry point when starting Tomcat via the provided scripts . @param args Command line arguments to be processed
public static void main(String args[]) {
        if (daemon == null) {
            Bootstrap bootstrap = new Bootstrap();
            try {
                bootstrap.init();
            } catch (Throwable t) {
                handleThrowable(t);
                t.printStackTrace();
                return;
            }
            daemon = bootstrap;
        } else {
            Thread.currentThread().setContextClassLoader(daemon.catalinaLoader);
        }
        try {
            String command = "start";
            if (args.length > 0) {
                command = args[args.length - 1];
            }
            if (command.equals("startd")) {
                args[args.length - 1] = "start";
                daemon.load(args);
                daemon.start();
            } else if (command.equals("stopd")) {
                args[args.length - 1] = "stop";
                daemon.stop();
            } else if (command.equals("start")) {
                daemon.setAwait(true);
                daemon.load(args);
                Server
                daemon.start();
            } else if (command.equals("stop")) {
                daemon.stopServer(args);
            } else if (command.equals("configtest")) {
                daemon.load(args);
                if (null==daemon.getServer()) {
                    System.exit(1);
                }
                System.exit(0);
            } else {
                log.warn("Bootstrap: command \"" + command + "\" does not exist.");
            }
        } catch (Throwable t) {
            if (t instanceof InvocationTargetException &&
                    t.getCause() != null) {
                t = t.getCause();
            }
            handleThrowable(t);
            t.printStackTrace();
            System.exit(1);
        }
    }
public static void main ( String args [ ] ) { if ( daemon == null ) { Bootstrap bootstrap = new Bootstrap ( ) ; try { bootstrap . init ( ) ; } catch ( Throwable t ) { handleThrowable ( t ) ; t . printStackTrace ( ) ; return ; } daemon = bootstrap ; } else { Thread . currentThread ( ) . setContextClassLoader ( daemon . catalinaLoader ) ; } try { String command = "start" ; if ( args . length > 0 ) { command = args [ args . length - 1 ] ; } if ( command . equals ( "startd" ) ) { args [ args . length - 1 ] = "start" ; daemon . load ( args ) ; daemon . start ( ) ; } else if ( command . equals ( "stopd" ) ) { args [ args . length - 1 ] = "stop" ; daemon . stop ( ) ; } else if ( command . equals ( "start" ) ) { daemon . setAwait ( true ) ; daemon . load ( args ) ; daemon . start ( ) ; } else if ( command . equals ( "stop" ) ) { daemon . stopServer ( args ) ; } else if ( command . equals ( "configtest" ) ) { daemon . load ( args ) ; if ( null == daemon . getServer ( ) ) { System . exit ( 1 ) ; } System . exit ( 0 ) ; } else { log . warn ( "Bootstrap: command \"" + command + "\" does not exist." ) ; } } catch ( Throwable t ) { if ( t instanceof InvocationTargetException && t . getCause ( ) != null ) { t = t . getCause ( ) ; } handleThrowable ( t ) ; t . printStackTrace ( ) ; System . exit ( 1 ) ; } }
Main method and entry point when starting Tomcat via the provided
 scripts.
Main method and entry point when starting Tomcat via the provided scripts .
//初始化，获得加载器 // Don't set daemon until init() has completed // 初始化完成之前不要设置守护进程 //执行初始化方法， //设置daemon为新创建的实例. // When running as a service the call to stop will be on a new // thread so make sure the correct class loader is used to prevent // a range of class not found exceptions. // 停止服务 // start 参数 //加载参数,命令截取 //启动 //设置server等待请求状态，为开，关做准备 , 阻塞main线程 //加载参数 //加载Server //启动Server // Unwrap the Exception for clearer error reporting