www_site/docs/production-deployment-2026-09-12.md

45 lines
3.7 KiB
Markdown
Raw Permalink 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.

# 生产部署记录2026-09-12
## 发布
- 发布提交:`49a916b`(首页菜单增加"主页"入口;全站按钮改为透明底 + hover 动态背景,按钮内文字前加品牌 logo 小图标 `components/brand-icon.tsx`CMS 中文化标签、i18nen/zh、自定义退出按钮 `/cms/api/cms-logout`)。
- 发布目录:`/home/flym/releases/49a916b-www`www服务器构建、`/home/flym/releases/cms-49a916b`CMS服务器构建
- 软链:`kaotings-www`→`releases/49a916b-www`、`kaotings-cms`→`releases/cms-49a916b`、`kaotings-api`→`releases/ad87a71/services/api`(未变更,未重启)。
- 数据库迁移CMS 改动仅为标签/i18n/组件,无字段结构变化)。
## 过程
1. 本地提交 `49a916b` 并推送 origin`57c854a..49a916b`)。
2. `git archive` 打包 www 全量与 `apps/cms`scp 上传(`kaotings_deploy` 密钥)。
3. 服务器 `cp -a` 上一发布后解包覆盖;关键文件 SHA256 与本地一致(`lib/content.ts`、`brand-icon.tsx`、`payload.config.ts`)。
4. 服务器构建www`NODE_ENV=production CMS_PUBLIC_API_URL=http://127.0.0.1:3001/cms npm run build`)与 CMS`npm run build`)均成功。
5. CMS 产物完整性:`.next/node_modules` 经符号链接实文件 319 个pino 207符合"服务器构建"要求,无 09-11 的 Windows 构建空目录问题。
6. 切换顺序:先 CMS重启 `kaotings-cms`,验证 200→ 再 www重启 `kaotings-web`)。软链属主为 flym切换本身无需 sudo`systemctl restart` 使用 sudo。
## 回滚
- www 回滚:`kaotings-www`→`releases/ad87a71-www` + `systemctl restart kaotings-web`
- CMS 回滚:`kaotings-cms`→`releases/cms-ad87a71-c` + `systemctl restart kaotings-cms`
- 无迁移,回滚无数据兼容问题。
## 验收
- `systemctl is-active`kaotings-api / kaotings-cms / kaotings-web 均 active。
- `GET /healthz`127.0.0.1:8000 与 https://www.kaotings.comok / 200。
- www 首页(本地 3000 与外部 https 一致):主导航含"主页"(→`/`);登录/联系我们为统一透明底按钮hover 出背景);页面 `/_next/image` 图标 18 处(含按钮 logo 与品牌标);`/icon.png` 200。
- CMS`/cms/admin` 200`/cms/api/products?where[status][equals]=published` 200www 产品列表依赖正常)。
- 管理端中文标签/i18n 与退出按钮:代码已上线,登录态界面待人工目视确认。
## 当日追加发布(均为仅 www 或 www+API同法操作
| 提交 | 内容 | 发布目录 |
| --- | --- | --- |
| `a06b5f4` | 所有按钮 hover 统一为登录按钮的青色亮底,去除橙色 | `releases/a06b5f4-www` |
| `d296b7a` | 页头登录态感知(我的页面/退出登录);修复 `lib/admin.ts` 请求丢失 Content-Type 导致删除用户 422 | `releases/d296b7a-www` |
| `af5b4af` | 退出登录后统一跳首页(页头与账户中心) | `releases/af5b4af-www` |
| `86fc51e` | 管理后台 TTS 配置(迁移 `007_tts_settings.sql`DB 优先于 envGET/PUT `/admin/tts/settings` + POST `/admin/tts/settings/test` 探测worker 动态读配置,兼容 mp3 | `releases/86fc51e`www + API 同目录) |
- `86fc51e` 已应用迁移schema_migrations 001007 齐全);`/api/v1/admin/tts/settings` 未登录 401三服务 active外部首页 200。
- 当前软链:`kaotings-www`→`releases/86fc51e`、`kaotings-api`→`releases/86fc51e/services/api`、`kaotings-cms`→`releases/cms-49a916b`。
- 待办管理员在后台“TTS 配置”页填入上游地址与 API Key探测通过后保存解决生产 `UPSTREAM_NOT_CONFIGURED`;上游凭据仍建议只走后台配置,不写入 api.env。