init: chongming 项目模板(init.py 初始化骨架 + 内置插件最小示例)
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
[default]
|
||||
app.debug = false
|
||||
app.description = "{{app_name}} — chongming 网关项目"
|
||||
app.name = "{{app_name}}"
|
||||
app.version = "0.1.0"
|
||||
env = "production"
|
||||
prefix = "/api/v1"
|
||||
upload_path = "uploads"
|
||||
|
||||
[zenoh]
|
||||
json5_path = "./config/zenoh_config.json5"
|
||||
|
||||
[cache]
|
||||
backend = "sqlite"
|
||||
path = "./cache_data/cache.db"
|
||||
# 配置优先来源模式(同时决定 [workers.config] 与 count 在启动时的取舍):
|
||||
# "cache"(本模板默认)= 以缓存为准:chongming-cache 为单一事实来源,插件初始化即读缓存值,
|
||||
# 管理接口(/admin/workers/<type>/config、/scale)改动跨重启保持;
|
||||
# toml 仅在缓存缺失时引导。启动日志会提示 toml 与缓存的差异键
|
||||
# (以缓存为准);如需让 toml 改动生效,先删除 worker:cm:configs:<type>
|
||||
# (运行时配置)/ worker:cm:counts:<type>(副本数)缓存键再重启。
|
||||
# "toml" = 以文件为准:启动时用 config/workers/<type>/config.toml 的
|
||||
# [workers.config] 与 count 覆盖写入缓存(前端读缓存 → 显示 toml 值);
|
||||
# 管理接口改动仅本次运行有效,重启网关即被文件覆盖。
|
||||
launch_worker_count = "cache"
|
||||
|
||||
[security]
|
||||
algorithm = "HS256"
|
||||
secret_key = "your-secret-key-change-in-production"
|
||||
|
||||
[production]
|
||||
debug = false
|
||||
env = "production"
|
||||
|
||||
[production.server]
|
||||
# 启动参数对各服务器通用(由 main.py 的转换函数映射,无需按服务器改配置);
|
||||
# 服务器/副本数可用环境变量覆盖:APP_SERVER=granian|uvicorn|gunicorn、APP_WORKERS=<N>
|
||||
access_log = false
|
||||
host = "0.0.0.0"
|
||||
port = 8000
|
||||
reload = false
|
||||
timeout_keep_alive = 65
|
||||
workers = 4
|
||||
|
||||
[production.logging]
|
||||
backup_count = 5 # 最多保存 10 个日志文件
|
||||
file = "logs"
|
||||
format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
||||
level = "INFO"
|
||||
max_size = 10485760 # 10MB
|
||||
access_sample_rate = 0.1
|
||||
|
||||
[production.cors]
|
||||
allow_credentials = true
|
||||
allow_headers = ["Content-Type", "Authorization", "Accept"]
|
||||
allow_methods = ["GET", "POST", "PUT", "DELETE", "OPTIONS"]
|
||||
allow_origins = ["http://localhost:5173", "http://127.0.0.1:5173"]
|
||||
max_age = 600
|
||||
|
||||
[production.mqtt]
|
||||
enabled = true
|
||||
host = "0.0.0.0"
|
||||
port = 1883
|
||||
# 是否由网关启动内嵌 amqtt Broker 子进程:
|
||||
# true (默认)= 网关自带 amqtt Broker,host/port 为 Broker 监听地址
|
||||
# false = 使用外部 MQTT Broker,网关仅启动 Bridge 客户端连接
|
||||
# host/port 需指向外部 Broker 地址(如 "192.168.1.10")
|
||||
use_embedded_broker = true
|
||||
# MQTT Broker 认证(可选,默认匿名):
|
||||
# - 内嵌 Broker(use_embedded_broker=true):配置后要求所有客户端(含网关 Bridge)
|
||||
# 用该账号密码连接,未配置则保持匿名
|
||||
# - 外部 Broker:网关 Bridge 用该账号密码连接(broker 侧自行配置对应账号)
|
||||
# 注意:密码为明文存储,生产环境建议使用外部 Broker + 环境变量注入
|
||||
# username = "chongming"
|
||||
# password = "change-me"
|
||||
|
||||
# MQTT Bridge 额外订阅主题推荐声明在各插件自己的配置里:
|
||||
# config/workers/<type>/config.toml → [[workers.mqtt_topics]]
|
||||
# (如 aibox_sophon_adapter 插件的 /board_ping 心跳主题)
|
||||
# 全局 [<env>.mqtt].custom_topics 仍可作为通用兜底(可选,不推荐)。
|
||||
|
||||
[production.mqtt.broker]
|
||||
# amqtt Broker 可选配置,默认允许匿名连接
|
||||
# 详细参数参考: https://github.com/Yakifo/amqtt
|
||||
|
||||
[production.module_system]
|
||||
# 运行期模块银行加载清单(frozen 产物用):网关本体是普通依赖包(chongming-gateway,
|
||||
# 已由 PyInstaller/Nuitka 打进产物),只有内置插件经模块银行加载。
|
||||
path = [
|
||||
"resources/plugins.mbank",
|
||||
]
|
||||
type = "module-bank"
|
||||
|
||||
# 静态前端(可选):接入 Vue 前端后由 `uv run build` 的 vue 步骤打包为 static.svfs,
|
||||
# 再启用下面这段(否则静态文件服务会因文件缺失而启动失败):
|
||||
# [production.file_system]
|
||||
# path = "static.svfs"
|
||||
# type = "svfs"
|
||||
Reference in New Issue
Block a user