Tencent TAT Deployment

本目录包含两类 TAT 发布入口:

  • deploy_platform_tat_deploy.py:发布当前 deploy-platform 前端项目。
  • hyapp_tat_deploy.py:发布 HyApp 后端 Go 微服务,逻辑复制自 /Users/hy/Documents/hy/hyapp-server/deploy/tencent-tat

两者使用同一套 TAT/CLB 滚动部署模型:可选 CLB 摘流TAT 远端更新 docker.env 镜像并重启 systemd unit健康恢复后恢复权重。

Deploy Platform

脚本只操作以下对象:

  • hyapp-deploy-platform systemd unit
  • hyapp-deploy-platform Docker 容器
  • /etc/hyapp/deploy-platform/docker.env

Prerequisites

  1. 目标机已安装 Tencent TAT agent。
  2. 目标机已安装 deploy/standalone/systemd/hyapp-deploy-platform.service
  3. 目标机已准备 /etc/hyapp/deploy-platform/docker.env
  4. 发布机安装腾讯云 SDK
python3 -m pip install tencentcloud-sdk-python

凭据通过环境变量或 --env-file 提供:

export TENCENTCLOUD_SECRET_ID="..."
export TENCENTCLOUD_SECRET_KEY="..."
export TENCENTCLOUD_REGION="me-saudi-arabia"

Inventory

cp deploy/tencent-tat/inventory.prod.example.json deploy/tencent-tat/deploy-platform.inventory.prod.json
vi deploy/tencent-tat/deploy-platform.inventory.prod.json

必须替换:

  • hosts.deploy-platform-1.instance_id
  • hosts.deploy-platform-1.private_ip
  • 如果前面挂 CLBclb.enabled 改成 true,并设置真实 load_balancer_id / listener_ids

Commands

只看计划,不执行远端动作:

python3 deploy/tencent-tat/deploy_platform_tat_deploy.py plan \
  --inventory deploy/tencent-tat/deploy-platform.inventory.prod.json \
  --services deploy-platform

发现目标机当前状态:

python3 deploy/tencent-tat/deploy_platform_tat_deploy.py discover \
  --env-file /opt/hy-app-monitor/.env \
  --inventory deploy/tencent-tat/deploy-platform.inventory.prod.json \
  --services deploy-platform

滚动更新镜像:

python3 deploy/tencent-tat/deploy_platform_tat_deploy.py deploy \
  --env-file /opt/hy-app-monitor/.env \
  --inventory deploy/tencent-tat/deploy-platform.inventory.prod.json \
  --services deploy-platform \
  --tag 20260514-1800 \
  --yes

只重启,不改镜像:

python3 deploy/tencent-tat/deploy_platform_tat_deploy.py restart \
  --env-file /opt/hy-app-monitor/.env \
  --inventory deploy/tencent-tat/deploy-platform.inventory.prod.json \
  --services deploy-platform \
  --yes

Failure Boundary

如果启用 CLB脚本会先把当前实例权重改为 0TAT 重启成功并通过 Docker health 后再恢复权重。重启或健康检查失败时,脚本停止后续步骤,已经摘流的实例保持权重 0,需要人工确认后恢复。

HyApp Services

平台后续接服务端执行器时,直接调用当前仓库内的 HyApp 微服务发布脚本:

python3 deploy/tencent-tat/hyapp_tat_deploy.py plan \
  --inventory deploy/tencent-tat/hyapp-services.inventory.prod.example.json \
  --services gateway-service,room-service,user-service

生产使用时复制成真实 inventory

cp deploy/tencent-tat/hyapp-services.inventory.prod.example.json deploy/tencent-tat/hyapp-services.inventory.prod.json
vi deploy/tencent-tat/hyapp-services.inventory.prod.json

HyApp Testbox

测试机部署不走生产镜像仓库,也不摘 CLB。当前模式是测试机自己拉取远端 test 分支:

  • 后端测试机:43.165.195.39 / 10.11.0.2,实例 lhins-q0m38zc6
  • 代码目录:/opt/hyapp-server-test/source
  • 部署脚本:/opt/hyapp-server-test/bin/deploy.sh
  • 自动轮询:hyapp-server-test-deploy.timer,每分钟检查一次 test 分支。
  • 成功条件Compose 服务全部 healthy 后才写入 /opt/hyapp-server-test/.deployed_commit
  • 后台前端:广州机 172.16.0.10:7001,公网 http://1.14.164.2:7001/

测试机 Go 服务 YAML 通过只读 TAT 接口读取:

python3 deploy/tencent-tat/hyapp_testbox_config.py configs \
  --env-file /opt/hy-app-monitor/.env \
  --services gateway-service,room-service,admin-server

默认返回会遮罩 secretpasswordtokenkey 等字段;确实需要原始值时,服务端必须显式设置 HYAPP_TESTBOX_CONFIG_ALLOW_RAW=1,并在 API 请求里带 raw=1