modify: 网关拆为独立包 chongming-gateway(源码迁出到 utils/gateway,打包只留 plugins.mbank)

This commit is contained in:
2026-10-13 17:29:38 +08:00
parent ac7ddb7445
commit 6d087fa4e3
44 changed files with 298 additions and 5594 deletions
+6 -7
View File
@@ -3,18 +3,17 @@ import sys
from utils.launch import init_module_bank
from utils.config import ConfigLoader
# 加载配置文件并初始化模块银行
# 加载配置文件并初始化模块银行(当前只剩内置插件 plugins.mbank)
config = ConfigLoader("config.toml")
init_module_bank(config)
# 从数据库动态导入 app 模块
# 该模块存储在 SQLite 数据库中,通过自定义导入机制加载
# 网关本体是普通依赖包(chongming-gateway),直接导入即可——打包时
# PyInstaller/Nuitka 也沿这行静态收集网关及其依赖。
# 插件(plugins 包)由上面的模块银行提供,在 lifespan 启动时被网关按配置加载。
try:
import app # type: ignore
app_instance = app.app
from chongming.app import app as app_instance
except ImportError as e:
print(f"无法从数据库导入 app 模块: {e}")
print(f"无法导入网关(chongming.app): {e}")
sys.exit(1)
# 暴露 ASGI 应用实例,供 uvicorn 服务器使用