From 93cf5c4e2f550eb8768e0a6666faf41aedd8f324 Mon Sep 17 00:00:00 2001 From: LamGC Date: Fri, 22 Apr 2022 18:15:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9B=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=AE=BF=E9=97=AE=E6=AF=94=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E6=97=A9=E8=80=8C=E5=AF=BC=E8=87=B4=E7=9A=84=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 由于 Launcher 比 initialFiles 更早的执行, 调用 Const 导致更早的访问了未初始化的文件, 导致第一次启动会出现错误. 改动中将 Launcher 移入 main 方法不会有影响, 相比于在 AppPaths. 中初始化会更安全. --- scalabot-app/src/main/kotlin/AppMain.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scalabot-app/src/main/kotlin/AppMain.kt b/scalabot-app/src/main/kotlin/AppMain.kt index b8f2ff1..4f290a0 100644 --- a/scalabot-app/src/main/kotlin/AppMain.kt +++ b/scalabot-app/src/main/kotlin/AppMain.kt @@ -13,14 +13,14 @@ import kotlin.system.exitProcess private val log = KotlinLogging.logger { } -private val launcher = Launcher() - .registerShutdownHook() - fun main(args: Array): Unit = runBlocking { log.info { "ScalaBot 正在启动中..." } log.info { "数据目录: ${AppPaths.DATA_ROOT}" } log.debug { "启动参数: ${args.joinToString(prefix = "[", postfix = "]")}" } initialFiles() + + val launcher = Launcher() + .registerShutdownHook() if (Const.config.metrics.enable) { startMetricsServer() }