服务:
cran-code.service(systemd),uv tool 安装于/root/.local/share/uv/tools/cran-code/,端口 5496,Nginx 反代 crys.tt2.li,--public模式。启动脚本/usr/local/bin/cran-code-web会 source~/.cran/server.env。
cd /root/workspace/crys
uv tool install --force --refresh --from . cran-code # --refresh 必须!否则可能复用旧 wheel 缓存
systemctl restart cran-code.service
sleep 10
curl -s -o /dev/null -w "%{http_code}\n" https://crys.tt2.li/ # 期望 200(刚重启可能短暂 502,等几秒再试)验证安装内容(防缓存坑):
grep -c "<新函数/特征串>" /root/.local/share/uv/tools/cran-code/lib/python3.14/site-packages/cran_code/<file>.pycd /root/workspace/crys/web
NODE_OPTIONS="--max-old-space-size=1800" npm run build # 约 2-10 分钟
cp -r dist/* ../src/cran_code/web/static/ # 仓库内静态目录
cp -r dist/* /root/.local/share/uv/tools/cran-code/lib/python3.14/site-packages/cran_code/web/static/ # 已安装工具目录
systemctl restart cran-code.service
# 验证:served index.html 的 bundle hash 与新构建一致
curl -s https://crys.tt2.li/ | grep -o 'index-[A-Za-z0-9_-]*\.js' | head -1- 新表:
db/models.py添加模型即可(启动时create_all自动建表)。 - 已有表加列:无自动迁移,需手工 SQL 或写迁移脚本。
~/.cran/config.toml改动后:worker 在下次启动时读取;可用POST /api/v2/providers/select(admin)触发运行中 worker 重启,或直接重启服务。- 永远不要把 config.toml / server.env 提交进仓库。
- 代码:
git revert或 checkout 旧 commit 后重新走后端部署流程。 - 前端:重新构建旧版本 dist 并同步两个静态目录。
- 数据库:本项目无降级迁移;改表前备份
~/.cran/cran.db。
https://crys.tt2.li/200;bundle hash 正确。/api/v2/providers/未授权 401。journalctl -u cran-code.service -n 50 --no-pager无新 traceback。- 真实开一个会话发消息,确认 worker 正常(
/px或直连按 key 来源走通)。