src/main/java/com/linecorp/armeria/server/Server.java
/**
     * Starts this {@link Server} to listen to the {@link ServerPort}s specified in the {@link ServerConfig}.
     * Note that the startup procedure is asynchronous and thus this method returns immediately. To wait until
     * this {@link Server} is fully started up, wait for the returned {@link Future}:
     * <pre>{@code
     * ServerBuilder builder = new ServerBuilder();
     * ...
     * Server server = builder.build();
     * server.start().sync();
     * }</pre>
     *
     * @param promise the {@link Promise} to notify when the startup procedure is finished
     * @return {@code promise}
     */
Starts this  Server to listen to the  ServerPorts specified in the  ServerConfig.
Note that the startup procedure is asynchronous and thus this method returns immediately. To wait until
this  Server is fully started up, wait for the returned  Future:
{@code
ServerBuilder builder = new ServerBuilder();

Server server = builder.build();
server.start().sync();
}

@param promise the  Promise to notify when the startup procedure is finished
@return  promise
Starts this Server to listen to the ServerPorts specified in the ServerConfig . Note that the startup procedure is asynchronous and thus this method returns immediately . To wait until this Server is fully started up wait for the returned Future : { @code ServerBuilder builder = new ServerBuilder () ; Server server = builder . build () ; server . start () . sync () ; } @param promise the Promise to notify when the startup procedure is finished @return promise
public Future<Void> start(Promise<Void> promise) {
        requireNonNull(promise, "promise");
        final State state = stateManager.state();
        switch (state.type) {
        case STOPPING:
            state.future.addListener(future -> start(promise));
            return promise;
        }
        if (!stateManager.enterStarting(promise, this::stop0)) {
            assert promise.cause() != null;
            return promise;
        }
        try {
            if (NativeLibraries.isEpollAvailable()) {
                bossGroup = new EpollEventLoopGroup(1, DEFAULT_THREAD_FACTORY_BOSS_EPOLL);
                workerGroup = new EpollEventLoopGroup(config.numWorkers(), DEFAULT_THREAD_FACTORY_EPOLL);
            } else {
                bossGroup = new NioEventLoopGroup(1, DEFAULT_THREAD_FACTORY_BOSS_NIO);
                workerGroup = new NioEventLoopGroup(config.numWorkers(), DEFAULT_THREAD_FACTORY_NIO);
            }
            final List<ServerPort> ports = config().ports();
            final AtomicInteger remainingPorts = new AtomicInteger(ports.size());
            if (config().gracefulShutdownQuietPeriod().isZero()) {
                gracefulShutdownHandler = null;
            } else {
                gracefulShutdownHandler =
                        GracefulShutdownHandler.create(config().gracefulShutdownQuietPeriod(),
                                                       config().blockingTaskExecutor());
            }
            for (ServerPort p: ports) {
                start(p).addListener(new ServerPortStartListener(remainingPorts, promise, p));
            }
        } catch (Throwable t) {
            promise.setFailure(t);
        }
        return promise;
    }
public Future < Void > start ( Promise < Void > promise ) { requireNonNull ( promise , "promise" ) ; final State state = stateManager . state ( ) ; switch ( state . type ) { case STOPPING : state . future . addListener ( future -> start ( promise ) ) ; return promise ; } if ( ! stateManager . enterStarting ( promise , this :: stop0 ) ) { assert promise . cause ( ) != null ; return promise ; } try { if ( NativeLibraries . isEpollAvailable ( ) ) { bossGroup = new EpollEventLoopGroup ( 1 , DEFAULT_THREAD_FACTORY_BOSS_EPOLL ) ; workerGroup = new EpollEventLoopGroup ( config . numWorkers ( ) , DEFAULT_THREAD_FACTORY_EPOLL ) ; } else { bossGroup = new NioEventLoopGroup ( 1 , DEFAULT_THREAD_FACTORY_BOSS_NIO ) ; workerGroup = new NioEventLoopGroup ( config . numWorkers ( ) , DEFAULT_THREAD_FACTORY_NIO ) ; } final List < ServerPort > ports = config ( ) . ports ( ) ; final AtomicInteger remainingPorts = new AtomicInteger ( ports . size ( ) ) ; if ( config ( ) . gracefulShutdownQuietPeriod ( ) . isZero ( ) ) { gracefulShutdownHandler = null ; } else { gracefulShutdownHandler = GracefulShutdownHandler . create ( config ( ) . gracefulShutdownQuietPeriod ( ) , config ( ) . blockingTaskExecutor ( ) ) ; } for ( ServerPort p : ports ) { start ( p ) . addListener ( new ServerPortStartListener ( remainingPorts , promise , p ) ) ; } } catch ( Throwable t ) { promise . setFailure ( t ) ; } return promise ; }
Starts this {@link Server} to listen to the {@link ServerPort}s specified in the {@link ServerConfig}.
Starts this { @link Server } to listen to the { @link ServerPort } s specified in the { @link ServerConfig } .
// A user called start() to restart the server, but the server is not stopped completely. // Try again after stopping. // Initialize the event loop groups. // Initialize the server sockets asynchronously.