From d7532776b9d608632b91a6c658fcd72ca7c70d64 Mon Sep 17 00:00:00 2001 From: Piotr Jaszczyk Date: Tue, 22 Jan 2019 11:43:18 +0100 Subject: Close KafkaSender when handling SIGINT Closing KafkaSender should result in flushing any pending messages. Change-Id: Ib251f5ca3527266831189df542784cc17173d8dc Issue-ID: DCAEGEN2-1065 Signed-off-by: Piotr Jaszczyk --- .../veshv/healthcheck/factory/HealthCheckApiServer.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'sources/hv-collector-health-check/src/main') diff --git a/sources/hv-collector-health-check/src/main/kotlin/org/onap/dcae/collectors/veshv/healthcheck/factory/HealthCheckApiServer.kt b/sources/hv-collector-health-check/src/main/kotlin/org/onap/dcae/collectors/veshv/healthcheck/factory/HealthCheckApiServer.kt index 7aade34b..32486009 100644 --- a/sources/hv-collector-health-check/src/main/kotlin/org/onap/dcae/collectors/veshv/healthcheck/factory/HealthCheckApiServer.kt +++ b/sources/hv-collector-health-check/src/main/kotlin/org/onap/dcae/collectors/veshv/healthcheck/factory/HealthCheckApiServer.kt @@ -29,6 +29,7 @@ import org.onap.dcae.collectors.veshv.utils.ServerHandle import org.onap.dcae.collectors.veshv.utils.logging.Logger import reactor.core.publisher.Flux import reactor.core.publisher.Mono +import reactor.netty.DisposableServer import reactor.netty.http.server.HttpServer import reactor.netty.http.server.HttpServerRequest import reactor.netty.http.server.HttpServerResponse @@ -48,7 +49,10 @@ class HealthCheckApiServer(private val healthState: HealthState, fun start(): IO = IO { healthState().subscribe(healthDescription::set) val ctx = HttpServer.create() - .tcpConfiguration { it.addressSupplier { listenAddress } } + .tcpConfiguration { + it.addressSupplier { listenAddress } + .doOnUnbound { logClose() } + } .route { routes -> routes.get("/health/ready", ::readinessHandler) routes.get("/health/alive", ::livenessHandler) @@ -70,8 +74,13 @@ class HealthCheckApiServer(private val healthState: HealthState, private fun monitoringHandler(_req: HttpServerRequest, resp: HttpServerResponse) = resp.sendString(monitoring.lastStatus()) + private fun logClose() { + logger.info { "Health Check API closed" } + } + companion object { private val logger = Logger(HealthCheckApiServer::class) + } } -- cgit 1.2.3-korg