@Override
    public void serviceAdded(ServiceConfig cfg) throws Exception {
        if (server != null) {
            if (server != cfg.server()) {
                throw new IllegalStateException("cannot be added to more than one server");
            } else {
                return;
            }
        }

        server = cfg.server();
        server.addListener(new ServerListenerAdapter() {
            @Override
            public void serverStarting(Server server) throws Exception {
                serverStopping = false;
                if (healthCheckerListener != null) {
                    healthCheckers.stream().map(ListenableHealthChecker.class::cast).forEach(c -> {
                        c.addListener(healthCheckerListener);
                    });
                }
                healthCheckers.stream()
                              .filter(ScheduledHealthChecker.class::isInstance)
                              .map(ScheduledHealthChecker.class::cast)
                              .forEach(ScheduledHealthChecker::startHealthChecker);
            }

            @Override
            public void serverStarted(Server server) {
                if (startHealthy) {
                    serverHealth.setHealthy(true);
                }
            }

            @Override
            public void serverStopping(Server server) {
                serverStopping = true;
                serverHealth.setHealthy(false);
            }

            @Override
            public void serverStopped(Server server) throws Exception {
                if (healthCheckerListener != null) {
                    healthCheckers.stream().map(ListenableHealthChecker.class::cast).forEach(c -> {
                        c.removeListener(healthCheckerListener);
                    });
                }
                healthCheckers.stream()
                              .filter(ScheduledHealthChecker.class::isInstance)
                              .map(ScheduledHealthChecker.class::cast)
                              .forEach(ScheduledHealthChecker::stopHealthChecker);
            }
        });
    }
Returns a new builder which builds a new {@link HealthCheckService}.
core/src/main/java/com/linecorp/armeria/server/healthcheck/HealthCheckService.java