From ae411ce82922f36e53b9615c8aa1e96a597fadb8 Mon Sep 17 00:00:00 2001 From: LamGC Date: Wed, 29 Jun 2022 03:06:15 +0800 Subject: [PATCH] =?UTF-8?q?refactor(metrics):=20=E8=B0=83=E6=95=B4=20Metri?= =?UTF-8?q?csHttpServer=20=E6=B3=A8=E5=86=8C=E5=85=B3=E9=97=AD=E9=92=A9?= =?UTF-8?q?=E5=AD=90=E7=9A=84=E6=97=B6=E6=9C=BA.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将关闭钩子的时机调整到 main 方法中, 可以减少多余的钩子注册(比如测试时无需注册钩子, 却还是注册了). --- scalabot-app/src/main/kotlin/AppMain.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scalabot-app/src/main/kotlin/AppMain.kt b/scalabot-app/src/main/kotlin/AppMain.kt index ff0dd5d..41db020 100644 --- a/scalabot-app/src/main/kotlin/AppMain.kt +++ b/scalabot-app/src/main/kotlin/AppMain.kt @@ -33,7 +33,7 @@ fun main(args: Array): Unit = runBlocking { val launcher = Launcher() .registerShutdownHook() - startMetricsServer() + startMetricsServer()?.registerShutdownHook() if (!launcher.launch()) { exitProcess(1) } @@ -57,7 +57,6 @@ internal fun startMetricsServer(config: MetricsConfig = Const.config.metrics): H val httpServer = builder .build() - .registerShutdownHook() log.info { "运行指标服务器已启动. (Port: ${httpServer.port})" } return httpServer }