private StandardServer newServer(String hostname, Connector connector, TomcatServiceConfig config) {
        //
        // server <------ services <------ engines <------ realm
        //                                         <------ hosts <------ contexts
        //                         <------ connectors
        //                         <------ executors
        //

        final StandardEngine engine = new StandardEngine();
        engine.setName(config.engineName());
        engine.setDefaultHost(hostname);
        engine.setRealm(config.realm());
        engine.setBackgroundProcessorDelay(-1);

        final StandardService service = new StandardService();
        service.setName(config.serviceName());
        service.setContainer(engine);

        service.addConnector(connector);

        final StandardServer server = new StandardServer();

        final File baseDir = config.baseDir().toFile();
        server.setCatalinaBase(baseDir);
        server.setCatalinaHome(baseDir);
        server.setPort(EMBEDDED_TOMCAT_PORT);

        server.addService(service);

        // Add the web application context.
        // Get or create a host.
        StandardHost host = (StandardHost) engine.findChild(hostname);
        if (host == null) {
            host = new StandardHost();
            host.setName(hostname);
            engine.addChild(host);
        }

        if (!host.getAppBaseFile().mkdirs()) {
            throw new TomcatServiceException("failed to create app base file: " + host.getAppBaseFile());
        }

        // Create a new context and add it to the host.
        final Context ctx;
        try {
            ctx = (Context) Class.forName(host.getContextClass(), true, getClass().getClassLoader())
                                 .getDeclaredConstructor().newInstance();
        } catch (Exception e) {
            throw new TomcatServiceException("failed to create a new context: " + config, e);
        }

        // Use our own WebResourceRoot implementation so that we can load a ZIP/JAR file
        // whose extension is not '.war'.
        ctx.setResources(new ArmeriaWebResourceRoot(ctx, config));

        ctx.setPath(ROOT_CONTEXT_PATH);
        ctx.setDocBase(config.docBase().toString());
        ctx.addLifecycleListener(TomcatUtil.getDefaultWebXmlListener());
        ctx.setConfigFile(TomcatUtil.getWebAppConfigFile(ROOT_CONTEXT_PATH, config.docBase()));

        final ContextConfig ctxCfg = new ContextConfig();
        ctxCfg.setDefaultWebXml(TomcatUtil.noDefaultWebXmlPath());
        ctx.addLifecycleListener(ctxCfg);

        host.addChild(ctx);

        return server;
    }
See {@link StandardServer#await()} for more information about this magic number (-2),
which is used for an embedded Tomcat server that manages its life cycle manually.
tomcat10/src/main/java/com/linecorp/armeria/server/tomcat/ManagedConnectorFactory.java