Files
simon b6df028839 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 仓库初始化
2026-06-24 13:11:34 +08:00

65 lines
1.9 KiB
Python

import paramiko, time
NAS_HOST = "100.85.152.112"
NAS_PORT = 22
NAS_USER = "simon"
NAS_PASS = "Nas82829330"
def exec_and_read(c, cmd, wait=3):
stdin, stdout, stderr = c.exec_command(cmd)
time.sleep(wait)
while not stdout.channel.exit_status_ready():
time.sleep(0.2)
out = stdout.read().decode("utf-8", errors="replace")
return out
def main():
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(NAS_HOST, NAS_PORT, NAS_USER, NAS_PASS, timeout=15)
path = "/volume1/docker/gaokao-portal/backend"
# 1. 检查 seed_data.py 文件类型
out = exec_and_read(c, f"file {path}/seed_data.py", wait=3)
print(f" 文件类型: {out}")
# 2. 删除错误的 gzip 文件,重新上传正确的 seed_data.py
print(" 重新上传正确的 seed_data.py...")
# 用之前修改好的本地文件上传
local_file = r"C:\Users\simon\WorkBuddy\2026-05-20-15-22-53\deploy\backend\seed_data.py"
# 读取本地文件内容并上传
with open(local_file, "r", encoding="utf-8") as f:
content = f.read()
# 通过 echo 写入(处理特殊字符)
import base64
b64 = base64.b64encode(content.encode("utf-8")).decode("ascii")
# 上传
cmd = f"echo '{b64}' | base64 -d > {path}/seed_data.py"
exec_and_read(c, cmd, wait=3)
print(" 上传完成")
# 验证文件
out = exec_and_read(c, f"head -5 {path}/seed_data.py", wait=3)
print(f" 验证: {out[:200]}")
# 运行 seed
docker = "echo 'Nas82829330' | sudo -S /usr/local/bin/docker"
exec_and_read(c, f"cd {path} && python3 seed_data.py", wait=5)
# 重启后端
exec_and_read(c, f"{docker} restart gaokao-portal-backend-1", wait=3)
time.sleep(8)
# 检查问卷
out = exec_and_read(c, "curl -s http://localhost:8080/api/questionnaires", wait=3)
print(f"\n问卷结果: {out[:400]}")
c.close()
if __name__ == "__main__":
main()