mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-04-30 06:37:29 +00:00
refactor(metrics): 调整 MetricsHttpServer 注册关闭钩子的时机.
将关闭钩子的时机调整到 main 方法中, 可以减少多余的钩子注册(比如测试时无需注册钩子, 却还是注册了).
This commit is contained in:
parent
1afe0f07a8
commit
ae411ce829
@ -33,7 +33,7 @@ fun main(args: Array<String>): Unit = runBlocking {
|
|||||||
|
|
||||||
val launcher = Launcher()
|
val launcher = Launcher()
|
||||||
.registerShutdownHook()
|
.registerShutdownHook()
|
||||||
startMetricsServer()
|
startMetricsServer()?.registerShutdownHook()
|
||||||
if (!launcher.launch()) {
|
if (!launcher.launch()) {
|
||||||
exitProcess(1)
|
exitProcess(1)
|
||||||
}
|
}
|
||||||
@ -57,7 +57,6 @@ internal fun startMetricsServer(config: MetricsConfig = Const.config.metrics): H
|
|||||||
|
|
||||||
val httpServer = builder
|
val httpServer = builder
|
||||||
.build()
|
.build()
|
||||||
.registerShutdownHook()
|
|
||||||
log.info { "运行指标服务器已启动. (Port: ${httpServer.port})" }
|
log.info { "运行指标服务器已启动. (Port: ${httpServer.port})" }
|
||||||
return httpServer
|
return httpServer
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user