Files
chongming-template/public/server.py
T

21 lines
753 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# server.py
import sys
from utils.launch import init_module_bank
from utils.config import ConfigLoader
# 加载配置文件并初始化模块银行(当前只剩内置插件 plugins.mbank)
config = ConfigLoader("config.toml")
init_module_bank(config)
# 网关本体是普通依赖包(chongming-gateway),直接导入即可——打包时
# PyInstaller/Nuitka 也沿这行静态收集网关及其依赖。
# 插件(plugins 包)由上面的模块银行提供,在 lifespan 启动时被网关按配置加载。
try:
from chongming.app import app as app_instance
except ImportError as e:
print(f"无法导入网关(chongming.app): {e}")
sys.exit(1)
# 暴露 ASGI 应用实例,供 uvicorn 服务器使用
app = app_instance