MCPcopy Index your code
hub / github.com/AstrBotDevs/AstrBot / initialize

Method initialize

astrbot/core/core_lifecycle.py:142–277  ·  view source on GitHub ↗

初始化 AstrBot 核心生命周期管理类. 负责初始化各个组件, 包括 ProviderManager、PlatformManager、ConversationManager、PluginManager、PipelineScheduler、EventBus、AstrBotUpdator等。

(self)

Source from the content-addressed store, hash-verified

140 )
141
142 async def initialize(self) -> None:
143 """初始化 AstrBot 核心生命周期管理类.
144
145 负责初始化各个组件, 包括 ProviderManager、PlatformManager、ConversationManager、PluginManager、PipelineScheduler、EventBus、AstrBotUpdator等。
146 """
147 # 初始化日志代理
148 logger.info("AstrBot v" + VERSION)
149 if os.environ.get("TESTING", ""):
150 LogManager.configure_logger(
151 logger, self.astrbot_config, override_level="DEBUG"
152 )
153 LogManager.configure_trace_logger(self.astrbot_config)
154 else:
155 LogManager.configure_logger(logger, self.astrbot_config)
156 LogManager.configure_trace_logger(self.astrbot_config)
157
158 await self.db.initialize()
159
160 await html_renderer.initialize()
161
162 # 初始化 UMOP 配置路由器
163 self.umop_config_router = UmopConfigRouter(sp=sp)
164 await self.umop_config_router.initialize()
165
166 # 初始化 AstrBot 配置管理器
167 self.astrbot_config_mgr = AstrBotConfigManager(
168 default_config=self.astrbot_config,
169 ucr=self.umop_config_router,
170 sp=sp,
171 )
172 self.temp_dir_cleaner = TempDirCleaner(
173 max_size_getter=lambda: self.astrbot_config_mgr.default_conf.get(
174 TempDirCleaner.CONFIG_KEY,
175 TempDirCleaner.DEFAULT_MAX_SIZE,
176 ),
177 )
178
179 # apply migration
180 try:
181 await migra(
182 self.db,
183 self.astrbot_config_mgr,
184 self.umop_config_router,
185 self.astrbot_config_mgr,
186 )
187 except Exception as e:
188 logger.error(f"AstrBot migration failed: {e!s}")
189 logger.error(traceback.format_exc())
190
191 # 初始化事件队列
192 self.event_queue = Queue()
193
194 # 初始化人格管理器
195 self.persona_mgr = PersonaManager(self.db, self.astrbot_config_mgr)
196 await self.persona_mgr.initialize()
197
198 # 初始化供应商管理器
199 self.provider_manager = ProviderManager(

Callers 6

startMethod · 0.95
core_lifecycle_tdFunction · 0.95
core_lifecycle_tdFunction · 0.95
core_lifecycle_tdFunction · 0.95

Calls 15

UmopConfigRouterClass · 0.90
TempDirCleanerClass · 0.90
migraFunction · 0.90
PersonaManagerClass · 0.90
ProviderManagerClass · 0.90
PlatformManagerClass · 0.90
ConversationManagerClass · 0.90

Tested by 5

core_lifecycle_tdFunction · 0.76
core_lifecycle_tdFunction · 0.76
core_lifecycle_tdFunction · 0.76