v1.0.0 高考志愿门户完整修复
变更摘要: - [fix] 清理根目录 index.html 遗留代码(questionnaire-error + retryLoad 移除) - [fix] 副标题同步更新为自估591分 + 候选志愿546条数据校准 - [fix] 页脚注入版本号 v1.0.0 - [fix] 部署版 index.html: 取消家长标签,统一 filler-tianheng - [fix] Dashboard 文案修正(4份→2份线上问卷) - [fix] 清理冗余部署脚本(v1-v4归档至 archived_scripts/) - [fix] 等效位次工具纳入 deploy 目录 - [chore] .gitignore 初始化 - [init] Git 仓库初始化
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
"""
|
||||
重新构建镜像,确保 seed 正确执行
|
||||
"""
|
||||
import paramiko, time, base64, tarfile, io
|
||||
|
||||
NAS_HOST = "100.85.152.112"
|
||||
NAS_PORT = 22
|
||||
NAS_USER = "simon"
|
||||
NAS_PASS = "Nas82829330"
|
||||
NAS_DEPLOY_PATH = "/volume1/docker/gaokao-portal"
|
||||
DOCKER = f"echo '{NAS_PASS}' | sudo -S /usr/local/bin/docker"
|
||||
COMPOSE = f"{DOCKER} compose"
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(NAS_HOST, NAS_PORT, NAS_USER, NAS_PASS, timeout=20)
|
||||
|
||||
def run(cmd, desc="", timeout=30):
|
||||
if desc:
|
||||
print(f"[{desc}]")
|
||||
stdin, stdout, stderr = c.exec_command(cmd, timeout=timeout)
|
||||
time.sleep(1)
|
||||
ch = stdout.channel
|
||||
out = b""
|
||||
while not ch.exit_status_ready():
|
||||
if ch.recv_ready():
|
||||
out += ch.recv(4096)
|
||||
time.sleep(0.2)
|
||||
while ch.recv_ready():
|
||||
out += ch.recv(4096)
|
||||
result = out.decode().strip()
|
||||
if result:
|
||||
print(f" {result[:400]}")
|
||||
return result
|
||||
|
||||
# 1. 上传新的 seed_data.py
|
||||
with open("C:/Users/simon/WorkBuddy/2026-05-20-15-22-53/deploy/backend/seed_data.py", "rb") as f:
|
||||
content = f.read()
|
||||
b64_data = base64.b64encode(content).decode("ascii")
|
||||
|
||||
print("上传新的 seed_data.py...")
|
||||
transport = c.get_transport()
|
||||
ch = transport.open_session()
|
||||
ch.exec_command("base64 -d > /tmp/seed_data_new.py")
|
||||
ch.sendall(b64_data.encode())
|
||||
ch.shutdown_write()
|
||||
time.sleep(2)
|
||||
ch.recv_exit_status()
|
||||
|
||||
run(f"cp /tmp/seed_data_new.py {NAS_DEPLOY_PATH}/backend/seed_data.py", "替换 seed_data.py")
|
||||
|
||||
# 2. 删除旧数据库
|
||||
db_path = f"{NAS_DEPLOY_PATH}/backend/data/gaokao.db"
|
||||
run(f"rm -f {db_path}", "删除旧数据库")
|
||||
|
||||
# 3. 重新构建后端(会触发 CMD 中的 seed)
|
||||
run(f"cd {NAS_DEPLOY_PATH} && {COMPOSE} build backend --no-cache", "重新构建后端", timeout=180)
|
||||
|
||||
# 4. 启动容器
|
||||
run(f"cd {NAS_DEPLOY_PATH} && {COMPOSE} up -d backend", "启动后端", timeout=60)
|
||||
print("等待容器启动...")
|
||||
time.sleep(15)
|
||||
|
||||
# 5. 检查
|
||||
db_path = f"{NAS_DEPLOY_PATH}/backend/data/gaokao.db"
|
||||
result = run(f"sqlite3 {db_path} 'SELECT id, title FROM questionnaires;'", "问卷列表")
|
||||
print(f"\n问卷:\n{result}")
|
||||
|
||||
# 6. API
|
||||
result = run("curl -s http://localhost:8080/api/questionnaires", "问卷API", timeout=15)
|
||||
print(f"\nAPI:\n{result[:600]}")
|
||||
|
||||
# 7. 清理
|
||||
run("rm -f /tmp/seed_data_new.py", "清理")
|
||||
|
||||
c.close()
|
||||
print("\n完成!")
|
||||
Reference in New Issue
Block a user