2026-07-21 15:39:47 +08:00
|
|
|
|
[default]
|
|
|
|
|
|
app.debug = false
|
|
|
|
|
|
app.description = "基于 FastAPI 的 chongming 打包脚手架"
|
|
|
|
|
|
app.name = "chongming"
|
|
|
|
|
|
app.version = "chongming"
|
|
|
|
|
|
env = "development"
|
|
|
|
|
|
prefix = "/api/v1"
|
|
|
|
|
|
upload_path = "uploads"
|
|
|
|
|
|
|
|
|
|
|
|
[zenoh]
|
|
|
|
|
|
json5_path = "./config/zenoh_config.json5"
|
|
|
|
|
|
|
|
|
|
|
|
[cache]
|
2026-09-04 14:50:34 +08:00
|
|
|
|
# backend = "sqlite" # "sqlite"(默认,本机共享) | "redis"(跨主机)
|
|
|
|
|
|
backend = "redis"
|
|
|
|
|
|
# path = "./cache_data/cache.db"
|
2026-07-21 15:39:47 +08:00
|
|
|
|
|
2026-09-17 15:33:35 +08:00
|
|
|
|
# 配置优先来源模式(同时决定 [workers.config] 与 count 在启动时的取舍):
|
|
|
|
|
|
# "toml" (默认) = 以文件为准:启动时用 config/workers/<type>/config.toml 的
|
|
|
|
|
|
# [workers.config] 与 count 覆盖写入 cache(前端读 cache,因此随之显示
|
|
|
|
|
|
# toml 值);运行期经管理接口(/admin/workers/<type>/config、/scale)
|
|
|
|
|
|
# 改的值仅本次运行有效,重启网关即被文件覆盖。
|
|
|
|
|
|
# "cache" = 以缓存为准:chongming-cache 为单一事实来源,插件初始化即读缓存值,
|
|
|
|
|
|
# 管理接口改动跨重启保持;toml 仅在 cache 缺失时引导。启动日志会提示
|
|
|
|
|
|
# toml 与 cache 的差异键(以 cache 为准);如需让 toml 改动生效,先删除
|
|
|
|
|
|
# worker:cm:configs:<type>(运行时配置)/ worker:cm:counts:<type>(副本数)
|
|
|
|
|
|
# 缓存键再重启,或改用 "toml" 模式。
|
2026-08-27 09:49:47 +08:00
|
|
|
|
launch_worker_count = "toml"
|
|
|
|
|
|
|
2026-08-17 15:16:36 +08:00
|
|
|
|
# redis 后端专用(backend = "redis" 时生效,均有默认值)
|
2026-09-04 14:50:34 +08:00
|
|
|
|
redis_host = "127.0.0.1"
|
|
|
|
|
|
redis_port = 6379
|
|
|
|
|
|
redis_db = 0
|
|
|
|
|
|
redis_password = ""
|
|
|
|
|
|
redis_prefix = "chongming:"
|
2026-08-17 15:16:36 +08:00
|
|
|
|
|
2026-07-21 15:39:47 +08:00
|
|
|
|
[security]
|
|
|
|
|
|
algorithm = "HS256"
|
|
|
|
|
|
secret_key = "your-secret-key-change-in-production"
|
|
|
|
|
|
|
|
|
|
|
|
[development]
|
|
|
|
|
|
debug = true
|
|
|
|
|
|
env = "development"
|
|
|
|
|
|
|
|
|
|
|
|
[development.server]
|
|
|
|
|
|
access_log = false
|
|
|
|
|
|
host = "0.0.0.0"
|
|
|
|
|
|
port = 8000
|
|
|
|
|
|
reload = true
|
|
|
|
|
|
|
|
|
|
|
|
[development.logging]
|
|
|
|
|
|
file = "logs"
|
|
|
|
|
|
format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
|
|
|
|
|
level = "DEBUG"
|
2026-08-23 04:34:05 +08:00
|
|
|
|
# access 日志采样率:0.1 = 只记录 10% 的成功请求(错误 >=400 始终全量)
|
|
|
|
|
|
# 1.0 = 全量记录;配合异步日志队列降低高吞吐下主线程开销
|
|
|
|
|
|
access_sample_rate = 0.1
|
2026-07-21 15:39:47 +08:00
|
|
|
|
|
|
|
|
|
|
[development.cors]
|
|
|
|
|
|
allow_credentials = true
|
|
|
|
|
|
allow_headers = ["*"]
|
|
|
|
|
|
allow_methods = ["*"]
|
2026-08-27 09:49:47 +08:00
|
|
|
|
# 注意:allow_credentials=true 时 allow_origins 不能为 ["*"](starlette 会丢弃该 header),
|
2026-09-02 11:34:30 +08:00
|
|
|
|
# 需显式列出来源;本地前端 dev 端口会变化(5173/5174/...)。
|
|
|
|
|
|
allow_origins = [
|
|
|
|
|
|
"http://localhost:5173",
|
|
|
|
|
|
"http://127.0.0.1:5173",
|
|
|
|
|
|
"http://localhost:5174",
|
|
|
|
|
|
"http://127.0.0.1:5174",
|
|
|
|
|
|
]
|
2026-07-21 15:39:47 +08:00
|
|
|
|
|
2026-07-24 16:33:23 +08:00
|
|
|
|
[development.mqtt]
|
|
|
|
|
|
enabled = true
|
2026-09-04 14:50:34 +08:00
|
|
|
|
# host = "0.0.0.0"
|
|
|
|
|
|
host = "127.0.0.1"
|
2026-07-24 16:33:23 +08:00
|
|
|
|
port = 1883
|
2026-08-21 09:45:47 +08:00
|
|
|
|
# 是否由网关启动内嵌 amqtt Broker 子进程:
|
|
|
|
|
|
# true (默认)= 网关自带 amqtt Broker,host/port 为 Broker 监听地址
|
|
|
|
|
|
# false = 使用外部 MQTT Broker,网关仅启动 Bridge 客户端连接
|
|
|
|
|
|
# host/port 需指向外部 Broker 地址(如 "192.168.1.10")
|
2026-09-04 14:50:34 +08:00
|
|
|
|
# use_embedded_broker = true
|
|
|
|
|
|
use_embedded_broker = false
|
2026-08-21 09:45:47 +08:00
|
|
|
|
# MQTT Broker 认证(可选,默认匿名):
|
|
|
|
|
|
# - 内嵌 Broker(use_embedded_broker=true):配置后要求所有客户端(含网关 Bridge)
|
|
|
|
|
|
# 用该账号密码连接,未配置则保持匿名
|
|
|
|
|
|
# - 外部 Broker:网关 Bridge 用该账号密码连接(broker 侧自行配置对应账号)
|
|
|
|
|
|
# 注意:密码为明文存储,生产环境建议使用外部 Broker + 环境变量注入
|
|
|
|
|
|
# username = "chongming"
|
|
|
|
|
|
# password = "change-me"
|
2026-07-24 16:33:23 +08:00
|
|
|
|
|
2026-08-07 09:39:29 +08:00
|
|
|
|
# MQTT Bridge 额外订阅主题推荐声明在各插件自己的配置里:
|
|
|
|
|
|
# config/workers/<type>/config.toml → [[workers.mqtt_topics]]
|
|
|
|
|
|
# (如 aibox_sophon_adapter 插件的 /board_ping 心跳主题)
|
|
|
|
|
|
# 全局 [<env>.mqtt].custom_topics 仍可作为通用兜底(可选,不推荐)。
|
|
|
|
|
|
|
2026-07-24 16:33:23 +08:00
|
|
|
|
[development.mqtt.broker]
|
|
|
|
|
|
# amqtt Broker 可选配置,默认允许匿名连接
|
|
|
|
|
|
# 详细参数参考: https://github.com/Yakifo/amqtt
|
|
|
|
|
|
|
2026-07-21 15:39:47 +08:00
|
|
|
|
[plugins_worker]
|
|
|
|
|
|
config_path = "./config/workers/config.toml"
|
|
|
|
|
|
|
|
|
|
|
|
[pyinstaller_build_import]
|
2026-10-13 17:29:38 +08:00
|
|
|
|
# 打包收集清单(PyInstaller --hidden-import / Nuitka --include-module)。
|
2026-10-14 15:29:29 +08:00
|
|
|
|
# 网关本体(chongming-gateway 包)**未混淆时**能沿 `from chongming.app import app`
|
|
|
|
|
|
# 静态跟到;但 --encrypt 会先 PyArmor 混淆 main.py / server.py,此时静态分析跟不到,
|
|
|
|
|
|
# 网关入口包必须显式列出(见 base 前几项)。本清单保留三类:
|
|
|
|
|
|
# - 网关入口包(chongming / chongming.app 与骨架直接引用的子模块)
|
2026-10-13 17:29:38 +08:00
|
|
|
|
# - 动态导入、静态分析看不到的(granian 内部子模块、amqtt 插件、
|
|
|
|
|
|
# sqlite_vfs.contrib、chongming_worker 子模块等)
|
|
|
|
|
|
# - public 骨架自身(server / utils)与服务器可选实现(uvloop 等)
|
|
|
|
|
|
# 内置插件专属依赖(网关本体不 import,如 openai / bytedance)在根目录
|
|
|
|
|
|
# plugins_deps.toml 按插件分节维护,打包时由 build 自动并入本清单
|
2026-07-21 15:39:47 +08:00
|
|
|
|
base = [
|
2026-10-13 17:29:38 +08:00
|
|
|
|
"httptools",
|
|
|
|
|
|
"utils", # public 骨架
|
2026-07-21 15:39:47 +08:00
|
|
|
|
"utils.launch",
|
|
|
|
|
|
"utils.config",
|
|
|
|
|
|
"zenoh",
|
|
|
|
|
|
"chongming_worker",
|
2026-08-25 09:29:27 +08:00
|
|
|
|
"chongming_worker.contracts",
|
|
|
|
|
|
"chongming_worker.route_config",
|
|
|
|
|
|
"chongming_worker.routes_publisher",
|
2026-07-21 15:39:47 +08:00
|
|
|
|
"chongming_request",
|
2026-09-14 10:34:22 +08:00
|
|
|
|
"chongming_auth",
|
2026-07-21 15:39:47 +08:00
|
|
|
|
"server",
|
2026-10-14 15:29:29 +08:00
|
|
|
|
# 网关入口包:--encrypt 时 main.py / server.py 先被 PyArmor 混淆,里面的
|
|
|
|
|
|
# `from chongming.app import app` 对 PyInstaller 静态分析不可见 —— 漏了会在
|
|
|
|
|
|
# 打包期"成功"、产物启动即报
|
|
|
|
|
|
# "无法导入网关(chongming.app): No module named 'chongming'"
|
|
|
|
|
|
"chongming",
|
|
|
|
|
|
"chongming.app",
|
|
|
|
|
|
"chongming.app.core.logger",
|
|
|
|
|
|
"chongming.app.core.parent_death",
|
2026-10-13 17:29:38 +08:00
|
|
|
|
"module_bank", # 模块化打包工具
|
2026-07-21 15:39:47 +08:00
|
|
|
|
"sqlite_vfs",
|
|
|
|
|
|
"sqlite_vfs.core",
|
2026-09-14 10:34:22 +08:00
|
|
|
|
"sqlite_vfs.contrib",
|
|
|
|
|
|
"sqlite_vfs.contrib.fastapi_static",
|
2026-10-13 17:29:38 +08:00
|
|
|
|
"fastapi", # web 应用依赖
|
2026-07-21 15:39:47 +08:00
|
|
|
|
"fastapi.staticfiles",
|
|
|
|
|
|
"fastapi.middleware.cors",
|
2026-08-25 09:29:27 +08:00
|
|
|
|
"fastapi.middleware.gzip",
|
2026-10-13 17:29:38 +08:00
|
|
|
|
# "uvicorn",
|
|
|
|
|
|
"granian", # 备选服务器(APP_SERVER=granian,见 public/main.py),含 Rust 内核
|
2026-10-13 01:59:00 +08:00
|
|
|
|
"granian._compat",
|
|
|
|
|
|
"granian._futures",
|
|
|
|
|
|
"granian._granian",
|
|
|
|
|
|
"granian._imports",
|
|
|
|
|
|
"granian._internal",
|
|
|
|
|
|
"granian._loops",
|
|
|
|
|
|
"granian._signals",
|
|
|
|
|
|
"granian._types",
|
|
|
|
|
|
"granian.asgi",
|
|
|
|
|
|
"granian.constants",
|
|
|
|
|
|
"granian.errors",
|
|
|
|
|
|
"granian.http",
|
|
|
|
|
|
"granian.log",
|
|
|
|
|
|
"granian.net",
|
|
|
|
|
|
"granian.rsgi",
|
|
|
|
|
|
"granian.server",
|
|
|
|
|
|
"granian.server.common",
|
|
|
|
|
|
"granian.server.mp",
|
|
|
|
|
|
"granian.server.mt",
|
|
|
|
|
|
"granian.wsgi",
|
2026-08-17 15:16:36 +08:00
|
|
|
|
"chongming_cache",
|
|
|
|
|
|
"chongming_cache.backends",
|
2026-09-04 14:50:34 +08:00
|
|
|
|
"chongming_cache.backends.sqlite_",
|
2026-07-21 15:39:47 +08:00
|
|
|
|
"orjson",
|
|
|
|
|
|
"python_multipart",
|
2026-07-23 17:29:26 +08:00
|
|
|
|
"chongming_jwt",
|
2026-07-24 18:53:36 +08:00
|
|
|
|
"chongming_database",
|
|
|
|
|
|
"chongming_config",
|
|
|
|
|
|
"chongming_password",
|
2026-07-31 16:52:50 +08:00
|
|
|
|
"chongming_stream_manager",
|
2026-08-07 14:28:03 +08:00
|
|
|
|
"chongming_mqtt",
|
|
|
|
|
|
"chongming_mqtt.mqtt_forward",
|
|
|
|
|
|
"chongming_mqtt.mqtt_subscribe",
|
|
|
|
|
|
"chongming_mqtt.internal_mqtt",
|
2026-07-23 17:29:26 +08:00
|
|
|
|
"aiosqlite",
|
2026-08-17 17:28:27 +08:00
|
|
|
|
"asyncpg",
|
2026-08-05 14:20:04 +08:00
|
|
|
|
"aiofiles.os",
|
2026-07-23 17:29:26 +08:00
|
|
|
|
"sqlmodel",
|
2026-07-31 16:52:50 +08:00
|
|
|
|
"amqtt",
|
2026-10-13 17:29:38 +08:00
|
|
|
|
# amqtt 内嵌 Broker 的插件:amqtt 经 entry points 动态加载,静态分析看不到
|
|
|
|
|
|
# (Nuitka 尤其如此;缺了会在启动时告警 "Plugin import failed: amqtt.plugins....")
|
|
|
|
|
|
"amqtt.plugins.authentication",
|
|
|
|
|
|
"amqtt.plugins.logging_amqtt",
|
|
|
|
|
|
"amqtt.plugins.sys.broker",
|
|
|
|
|
|
"amqtt.plugins.topic_checking",
|
2026-07-31 16:52:50 +08:00
|
|
|
|
"aiofiles",
|
2026-07-21 15:39:47 +08:00
|
|
|
|
]
|
|
|
|
|
|
linux = [
|
2026-10-13 17:29:38 +08:00
|
|
|
|
# "gunicorn.glogging",
|
|
|
|
|
|
# "gunicorn.app",
|
|
|
|
|
|
# "gunicorn.app.wsgiapp",
|
|
|
|
|
|
"uvloop",
|
2026-07-21 15:39:47 +08:00
|
|
|
|
]
|
|
|
|
|
|
windows = []
|
|
|
|
|
|
|
|
|
|
|
|
[production.module_system]
|
2026-10-13 17:29:38 +08:00
|
|
|
|
# 网关本体(chongming-gateway 包)不再打进 .mbank:打包时 PyInstaller/Nuitka 从
|
|
|
|
|
|
# site-packages 静态收集(public/server.py 里 `from chongming.app import app`),
|
|
|
|
|
|
# 改网关走正常依赖升级(uv lock --upgrade-package chongming-gateway)而不是换 .mbank。
|
|
|
|
|
|
# 模块银行只剩内置插件一项:插件仍是加密交付 + 可只换 plugins.mbank 现场更新。
|
2026-07-21 15:39:47 +08:00
|
|
|
|
path = [
|
2026-10-13 17:29:38 +08:00
|
|
|
|
[
|
|
|
|
|
|
"resources/plugins.mbank",
|
|
|
|
|
|
"src/plugins",
|
|
|
|
|
|
"plugins",
|
|
|
|
|
|
],
|
2026-07-21 15:39:47 +08:00
|
|
|
|
]
|
2026-08-27 10:13:03 +08:00
|
|
|
|
type = "module-bank"
|