src/main/java/com/linecorp/armeria/server/Server.java
/**
     * Stops this {@link Server} to close all active {@link ServerPort}s. Note that the shutdown procedure is
     * asynchronous and thus this method returns immediately. To wait until this {@link Server} is fully
     * shut down, wait for the returned {@link Future}:
     * <pre>{@code
     * Server server = ...;
     * server.stop().sync();
     * }</pre>
     *
     * @param promise the {@link Promise} to notify when the shutdown procedure is finished
     * @return {@code promise}
     */
Stops this  Server to close all active  ServerPorts. Note that the shutdown procedure is
asynchronous and thus this method returns immediately. To wait until this  Server is fully
shut down, wait for the returned  Future:
{@code
Server server = ...;
server.stop().sync();
}

@param promise the  Promise to notify when the shutdown procedure is finished
@return  promise
Stops this Server to close all active ServerPorts . Note that the shutdown procedure is asynchronous and thus this method returns immediately . To wait until this Server is fully shut down wait for the returned Future : { @code Server server = ... ; server . stop () . sync () ; } @param promise the Promise to notify when the shutdown procedure is finished @return promise
public Future<Void> stop(Promise<Void> promise) {
        requireNonNull(promise, "promise");
        for (;;) {
            final State state = stateManager.state();
            switch (state.type) {
            case STOPPED:
                return promise.setSuccess(null);
            case STOPPING:
                state.future.addListener(f -> {
                    if (f.isSuccess()) {
                        promise.setSuccess(null);
                    } else {
                        promise.setFailure(f.cause());
                    }
                });
                return promise;
            case STARTED:
                if (!stateManager.enterStopping(state, promise)) {
                    continue;
                }
                return stop0(promise);
            case STARTING:
                state.future.addListener(f -> stop(promise));
                return promise;
            }
        }
    }
public Future < Void > stop ( Promise < Void > promise ) { requireNonNull ( promise , "promise" ) ; for ( ; ; ) { final State state = stateManager . state ( ) ; switch ( state . type ) { case STOPPED : return promise . setSuccess ( null ) ; case STOPPING : state . future . addListener ( f -> { if ( f . isSuccess ( ) ) { promise . setSuccess ( null ) ; } else { promise . setFailure ( f . cause ( ) ) ; } } ) ; return promise ; case STARTED : if ( ! stateManager . enterStopping ( state , promise ) ) { continue ; } return stop0 ( promise ) ; case STARTING : state . future . addListener ( f -> stop ( promise ) ) ; return promise ; } } }
Stops this {@link Server} to close all active {@link ServerPort}s. Note that the shutdown procedure is
 asynchronous and thus this method returns immediately.
Stops this { @link Server } to close all active { @link ServerPort } s . Note that the shutdown procedure is asynchronous and thus this method returns immediately .
// Someone else changed the state meanwhile; try again. // Wait until the start process is finished, and then try again.