refactor(launch): 增强关闭阶段的鲁棒性.

增加异常捕获, 防止由于部分 bot 发生异常而无法关闭其余机器人.
This commit is contained in:
LamGC 2022-04-10 16:27:20 +08:00
parent 4210efef3b
commit 9cdf10ccc2
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D

View File

@ -146,9 +146,16 @@ internal class Launcher : AutoCloseable {
@Synchronized
override fun close() {
botSessionMap.forEach {
log.info { "正在关闭机器人 `${it.key.botUsername}` ..." }
it.value.stop()
log.info { "已关闭机器人 `${it.key.botUsername}`." }
try {
if (!it.value.isRunning) {
return@forEach
}
log.info { "正在关闭机器人 `${it.key.botUsername}` ..." }
it.value.stop()
log.info { "已关闭机器人 `${it.key.botUsername}`." }
} catch (e: Exception) {
log.error(e) { "机器人 `${it.key.botUsername}` 关闭时发生异常." }
}
}
}