Files
Genarrative/deploy/env/pingora-direct-live.env.example
T
kdletters a7711d2dc3 引入Pingora独立网关正式化链路
新增 pingora-gateway 独立二进制 crate,覆盖路由、静态资源、压缩、接流保护、TLS 直连和访问日志能力。

新增 Nginx canary、realpath canary、direct preflight、direct live、direct enable 和 rollback 脚本。

新增 Pingora 切流证据包、命令证据、manifest 验真、根目录总审计和 release readiness 聚合门禁。

完善 API release、Jenkins、systemd、health patrol、生产部署和发布包自包含校验。

更新 Pingora 试点文档、Nginx README 与 Hermes 共享记忆。
2026-06-17 20:16:51 +08:00

66 lines
5.3 KiB
Bash
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.
# 复制到本机临时 shell 或 CI secret 环境后运行:
# npm run check:pingora-direct-live
# 该检查只读访问已经显式配置 TLS_LISTEN / HTTP_REDIRECT_LISTEN 的 pingora-gateway。
# 切换窗口建议先运行:
# npm run check:pingora-direct-preflight -- --env-file /etc/genarrative/pingora-gateway.env --require-live-env --systemd-cat --check-cert-readable --check-service-env-file --check-service-user-cert-readable --check-service-binary-executable --check-ports-free
# release readiness --require-direct 必须确认 TLS/HTTP redirect 端口已释放,复核 health patrol env 已切到 direct 模式,并提供 Pingora access log 路径用于 request_id 落盘校验。
# 直连启用前:
# /opt/genarrative/current/scripts/deploy/pingora-direct-enable.sh --no-status
# /opt/genarrative/current/scripts/deploy/pingora-direct-enable.sh --apply --preflight-env-file /etc/genarrative/pingora-gateway.env --preflight-check-cert-readable --preflight-check-service-env-file --preflight-check-service-user-cert-readable --preflight-check-service-binary-executable --preflight-check-ports-free --direct-https-base-url https://127.0.0.1 --direct-http-base-url http://127.0.0.1 --direct-host <域名> --direct-redirect-host <域名或host:port> --direct-spacetime-database <库名> --direct-pingora-access-log /var/log/genarrative/pingora-gateway.access.log
# 启用脚本会先执行 current release 自审,确认 pingora-gateway 可执行且 systemd ExecStart 指向 current release;自审失败时不会安装 direct-entry drop-in。
# 自审和 preflight 都通过后,启用脚本才会安装 drop-in、重启 Pingora、执行 direct live smoke,并强制 WSS subscribe 返回 101,同时用生成的 request_id 反查 Pingora access log。
# 直连接管后同步更新 /etc/genarrative/health-patrol.env
# GENARRATIVE_HEALTH_PATROL_GATEWAY_MODE=pingora-direct
# GENARRATIVE_HEALTH_PATROL_PUBLIC_BASE_URL=https://127.0.0.1
# GENARRATIVE_HEALTH_PATROL_PUBLIC_HOST=<域名>
# 然后用 node -- /opt/genarrative/current/scripts/check-production-health-patrol-env.mjs 复核。
# 直连验证失败时:
# /opt/genarrative/current/scripts/deploy/pingora-direct-rollback.sh --apply --reload-nginx --nginx-smoke-url http://127.0.0.1/healthz --nginx-smoke-host <域名>
# 回退脚本会先执行 nginx -treload 后确认 nginx.service 仍为 active,并用 smoke URL 证明 Nginx 入口可访问。
# 回退后把 GENARRATIVE_HEALTH_PATROL_GATEWAY_MODE 改回 nginx。
# 例如 https://127.0.0.1 或 https://genarrative.world。
GENARRATIVE_PINGORA_DIRECT_HTTPS_BASE_URL=https://127.0.0.1
# 单独 direct live 可选;release readiness --require-direct 必须提供,用于校验 HTTP 入口 301 到 HTTPS,并确认 ACME challenge 没被重定向吞掉。
GENARRATIVE_PINGORA_DIRECT_HTTP_BASE_URL=http://127.0.0.1
# 本机直连 127.0.0.1 时必须设置正式域名;direct live 会同时用作 Host header 和 TLS SNI。release readiness --require-direct 必须提供。只填域名或 host:port,不要填 https:// URL。
GENARRATIVE_PINGORA_DIRECT_HOST=
# 单独 direct live 可选;release readiness --require-direct 必须提供,用于显式校验 HTTP redirect Location 的 host。只填域名或 host:port,非标准端口本机 smoke 可设为 127.0.0.1:18443。
GENARRATIVE_PINGORA_DIRECT_REDIRECT_HOST=
# 可选:配置后会额外检查 /__genarrative_pingora/healthz 内部探针。
GENARRATIVE_PINGORA_DIRECT_PROBE_TOKEN=
# direct live 默认会对 wss://<HTTPS>/v1/database/<database>/subscribe 做 SpacetimeDB 握手检查;release readiness --require-direct 必须按目标环境显式设置。
GENARRATIVE_PINGORA_DIRECT_SPACETIME_DATABASE=genarrative-prod
# release readiness --require-direct 必须显式提供;direct live 会用每个请求生成的 X-Request-Id 反查 Pingora access log,证明直连流量真实进入 Pingora。
GENARRATIVE_PINGORA_DIRECT_PINGORA_ACCESS_LOG=/var/log/genarrative/pingora-gateway.access.log
GENARRATIVE_PINGORA_DIRECT_ACCESS_LOG_SINCE_LINES=2000
# direct live 单独运行时可设 true,要求 WSS subscribe 必须返回 101release readiness --require-direct 会自动强制该口径。
GENARRATIVE_PINGORA_DIRECT_REQUIRE_WSS_UPGRADE=true
# 只允许单独 direct live 临时排障时跳过 WSSrelease readiness --require-direct 会直接拒绝,正式切流必须保持 false。
GENARRATIVE_PINGORA_DIRECT_SKIP_WSS=false
# 仅本机自签证书 smoke 使用;生产必须保持 false。
GENARRATIVE_PINGORA_DIRECT_INSECURE_TLS=false
GENARRATIVE_PINGORA_DIRECT_TIMEOUT_MS=5000
# release readiness --require-direct 会先跑 direct-entry preflight;提供 env 文件后会强制检查 TLS/redirect/cert/key 配置。
GENARRATIVE_PINGORA_DIRECT_PREFLIGHT_ENV_FILE=/etc/genarrative/pingora-gateway.env
GENARRATIVE_PINGORA_DIRECT_PREFLIGHT_SYSTEMD_CAT=true
GENARRATIVE_PINGORA_DIRECT_PREFLIGHT_CHECK_CERT_READABLE=true
GENARRATIVE_PINGORA_DIRECT_PREFLIGHT_CHECK_SERVICE_ENV_FILE=true
GENARRATIVE_PINGORA_DIRECT_PREFLIGHT_CHECK_SERVICE_USER_CERT_READABLE=true
GENARRATIVE_PINGORA_DIRECT_PREFLIGHT_CHECK_SERVICE_BINARY_EXECUTABLE=true
GENARRATIVE_PINGORA_DIRECT_PREFLIGHT_CHECK_PORTS_FREE=true
# release readiness --require-direct 必须复核健康巡检 env,避免切直连后巡检仍按 Nginx 模式误报。
GENARRATIVE_PINGORA_DIRECT_HEALTH_PATROL_ENV_FILE=/etc/genarrative/health-patrol.env