老板要求:技术标识也要换,脚本啥的都换。
运行时
· 所有 logging.getLogger("api-gateway…") → "xiaoyin-gateway…"(main/metrics/circuit/settings/sessions/users/gomodels/video_owners/adapters)
· app/main.py 的上游 User-Agent 默认值 → xiaoyin-gateway/{VERSION}
· data/gateway.yaml 里 opencode 的 UA 覆盖 → xiaoyin-gateway/2.4.0
· run.py 启动横幅 → [xiaoyin-gateway]
脚本
· scripts/sync_models.py、sync_onemin.py 的探测 UA
· scripts/ci_check.sh 的横幅
前端
· 配置备份文件的 kind: api-gateway-backup → xiaoyin-gateway-backup
(导入逻辑本来就不校验 kind,旧备份照样能恢复)
· dist 产物同步打补丁,不用重新 build
文档
· README / CHANGELOG 里的服务名、`supervisorctl restart api-gateway:api-gateway_00` 等
· 另一个技能 dsh-plugin-publish 的敏感词规则里也提到了旧名,一并更新
唯一没动的
· .gitignore 里那行指向 /root/.trash/2026-09-13-api-gateway-cleanup 的注释 ——
那是磁盘上真实存在的历史目录名,改了反而指错地方
31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
"""启动脚本:python run.py
|
||
|
||
端口/宿主可被环境变量覆盖:
|
||
GATEWAY_PORT 覆盖端口(默认取配置文件 server.port,即 8808)
|
||
GATEWAY_HOST 覆盖宿主(默认取配置文件 server.host,即 127.0.0.1)
|
||
GATEWAY_CONFIG 指定配置文件路径(默认项目根/data/gateway.yaml)
|
||
|
||
说明:配置读取与 .env 加载统一由 app.main 模块完成(单一来源),
|
||
本脚本只负责把 app 对象喂给 uvicorn,避免重复解析 yaml / 重复加载 .env。
|
||
"""
|
||
|
||
import os
|
||
|
||
from app.main import CONFIG_PATH, app, config # 触发 app.main 模块加载(含 .env 与 yaml,单份)
|
||
|
||
host = os.environ.get("GATEWAY_HOST", config.server.host)
|
||
port = int(os.environ.get("GATEWAY_PORT", config.server.port))
|
||
|
||
if __name__ == "__main__":
|
||
import uvicorn
|
||
|
||
gs = int(os.environ.get("GATEWAY_GRACEFUL_SHUTDOWN", config.server.graceful_shutdown))
|
||
print(f"[xiaoyin-gateway] config={CONFIG_PATH} host={host} port={port} graceful_shutdown={gs}s")
|
||
# 直接传入 app 对象(而非 import string),避免 uvicorn 二次导入 app.main 而再算一次配置。
|
||
uvicorn.run(
|
||
app,
|
||
host=host,
|
||
port=port,
|
||
log_level=str(config.observability.log_level).lower(),
|
||
timeout_graceful_shutdown=gs,
|
||
) |