ci(vps-deploy): 纳入前端dist同步+API重启(治公网前端无管线手动步骤): Mac构建+tar+scp→VPS换dist(脚本入仓scripts/nas_sync,vps_update_dist.py); 重启加端口释放等待(防end→run竞态10048静默崩,今日实踩)+起服探活(上限10min) [nas]
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""VPS: 替换 frontend/dist 为最新构建(先备份旧版)。
|
||||
|
||||
用法(VPS 上): C:\\Python310\\python.exe -X utf8 C:\\sanguo_vnpy_v2\\scripts\\nas_sync\\vps_update_dist.py
|
||||
输入: C:\\sanguo_vnpy_v2\\dist_latest.tgz (Mac 构建后 scp 上来的 tar 包, 内容为 dist 根)
|
||||
输出: 尾行 DIST_UPDATE_DONE(成功标记, CI 用)
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import tarfile
|
||||
|
||||
ROOT = r"C:\sanguo_vnpy_v2"
|
||||
TGZ = os.path.join(ROOT, "dist_latest.tgz")
|
||||
DIST = os.path.join(ROOT, "frontend", "dist")
|
||||
BAK = os.path.join(ROOT, "frontend", "dist_bak")
|
||||
|
||||
if not os.path.exists(TGZ):
|
||||
raise SystemExit(f"tgz not found: {TGZ}")
|
||||
|
||||
if os.path.exists(BAK):
|
||||
shutil.rmtree(BAK)
|
||||
if os.path.exists(DIST):
|
||||
shutil.move(DIST, BAK)
|
||||
print("old dist ->", BAK, flush=True)
|
||||
os.makedirs(DIST, exist_ok=True)
|
||||
with tarfile.open(TGZ) as t:
|
||||
t.extractall(DIST)
|
||||
idx = os.path.join(DIST, "index.html")
|
||||
with open(idx, encoding="utf-8") as f:
|
||||
head = f.read(400)
|
||||
m = re.search(r"assets/index-[^\"']*", head)
|
||||
print("new index:", m.group(0) if m else "?", flush=True)
|
||||
print("DIST_UPDATE_DONE", flush=True)
|
||||
Reference in New Issue
Block a user