Files
AstrBot/astrbot/dashboard/dashboard_lifecycle.py
Soulter 750a93a1aa remove: 移除了 nakuru-project 库
但仍然使用其对 OneBot 的数据格式封装。
2024-12-02 19:31:33 +08:00

24 lines
833 B
Python

import asyncio
from multiprocessing import Process
from astrbot.core import logger
from astrbot.core.core_lifecycle import AstrBotCoreLifecycle
from .server import AstrBotDashboard
from astrbot.core.db import BaseDatabase
class AstrBotDashBoardLifecycle:
def __init__(self, db: BaseDatabase):
self.db = db
self.logger = logger
self.dashboard_server = None
async def start(self, core_lifecycle: AstrBotCoreLifecycle):
core_task = core_lifecycle.start()
self.dashboard_server = AstrBotDashboard(core_lifecycle, self.db)
task = asyncio.gather(core_task, self.dashboard_server.run())
try:
await task
except asyncio.CancelledError as e:
logger.info("🌈 正在关闭 AstrBot...")
core_lifecycle.stop()