@Override
    public Connector apply(String hostname) {

        // Create the connector with our protocol handler. Tomcat will call ProtocolHandler.setAdapter()
        // on its startup with the Coyote Adapter which gives an access to Tomcat's HTTP service pipeline.
        final Class<?> protocolType = TomcatService.PROTOCOL_HANDLER_CLASS;

        final Connector connector = new Connector(protocolType.getName());
        // We do not really open a port - just trying to stop the Connector from complaining.
        connector.setPort(0);

        final StandardServer server = newServer(hostname, connector, config);

        // Retrieve the components configured by newServer(), so we can use it in checkConfiguration().
        final Service service = server.findServices()[0];
        final Engine engine = TomcatUtil.engine(service, hostname);
        final StandardHost host = (StandardHost) engine.findChildren()[0];
        final Context context = (Context) host.findChildren()[0];

        // Apply custom configurators set via TomcatServiceBuilder.configurator()
        try {
            config.configurators().forEach(c -> c.accept(server));
        } catch (Throwable t) {
            throw new TomcatServiceException("failed to configure an embedded Tomcat", t);
        }

        // Make sure the configurators did not ruin what we have configured in this method.
        checkConfiguration(server, service, connector, engine, host, context);

        assert connector.getService().getServer() != null;
        return connector;
    }
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