From 7152517f2586a5b40726365a756087ddddc099ca Mon Sep 17 00:00:00 2001 From: Ivan Topolnjak Date: Mon, 11 Feb 2019 23:16:54 +0100 Subject: self-review changes and use a thread pool for the embedded status page server --- kamon-core/src/main/scala/kamon/StatusPage.scala | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'kamon-core/src/main/scala/kamon/StatusPage.scala') diff --git a/kamon-core/src/main/scala/kamon/StatusPage.scala b/kamon-core/src/main/scala/kamon/StatusPage.scala index e5c8ef52..1ac60c1b 100644 --- a/kamon-core/src/main/scala/kamon/StatusPage.scala +++ b/kamon-core/src/main/scala/kamon/StatusPage.scala @@ -1,9 +1,13 @@ package kamon import com.typesafe.config.Config -import kamon.status.{StatusPageServer, Status} +import kamon.status.{Status, StatusPageServer} +import org.slf4j.LoggerFactory + +import scala.util.{Failure, Success, Try} trait StatusPage { self: Configuration with ClassLoading with ModuleLoading with Metrics with Configuration => + private val _log = LoggerFactory.getLogger(classOf[StatusPage]) @volatile private var _statusPageServer: Option[StatusPageServer] = None private val _status = new Status(self._moduleRegistry, self._metricsRegistry, self) @@ -47,10 +51,20 @@ trait StatusPage { self: Configuration with ClassLoading with ModuleLoading with } private def startServer(hostname: String, port: Int, resourceLoader: ClassLoader): Unit = { - val server = new StatusPageServer(hostname, port, resourceLoader, _status) - server.start() + Try { + + val server = new StatusPageServer(hostname, port, resourceLoader, _status) + server.start() + server - _statusPageServer = Some(server) + } match { + case Success(server) => + _log.info(s"Status page started on http://$hostname:$port/") + _statusPageServer = Some(server) + + case Failure(t) => + _log.error("Failed to start the status page embedded server", t) + } } private def stopServer(): Unit = { -- cgit v1.2.3