@Override
        protected CompletionStage<Void> doStart(@Nullable Void arg) {
            if (config().gracefulShutdown().quietPeriod().isZero()) {
                gracefulShutdownSupport = GracefulShutdownSupport.createDisabled();
            } else {
                gracefulShutdownSupport =
                        GracefulShutdownSupport.create(config().gracefulShutdown().quietPeriod(),
                                                       config().blockingTaskExecutor());
            }

            // Initialize the server sockets asynchronously.
            final CompletableFuture<Void> future = new CompletableFuture<>();
            final List<ServerPort> ports = config().ports();

            final Iterator<ServerPort> it = ports.iterator();
            assert it.hasNext();

            final ServerPort primary = it.next();
            try {
                doStart(primary).addListener(new ServerPortStartListener(primary))
                                .addListener(new NextServerPortStartListener(this, it, future));
                // Chain the future to set up server metrics first before server start future is completed.
                return future.thenAccept(unused -> setupPendingResponsesMetrics());
            } catch (Throwable cause) {
                future.completeExceptionally(cause);
                return future;
            }
        }
Registers a JVM shutdown hook that closes this {@link Server} when the current JVM terminates.

@param whenClosing the {@link Runnable} will be run before closing this {@link Server}
core/src/main/java/com/linecorp/armeria/server/Server.java