Files
2026gaokaozhiyuan/debug_container.py
T
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

44 lines
1.2 KiB
Python

import paramiko, time
NAS_HOST = "100.85.152.112"
NAS_PORT = 22
NAS_USER = "simon"
NAS_PASS = "Nas82829330"
NAS_DEPLOY_PATH = "/volume1/docker/gaokao-portal"
DOCKER_BIN = "/usr/local/bin/docker"
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(NAS_HOST, NAS_PORT, NAS_USER, NAS_PASS, timeout=20)
# 使用 shell 执行
def shell(cmd):
"""通过 shell 执行,返回完整输出"""
transport = c.get_transport()
channel = transport.open_session()
channel.get_pty() # 获取 PTY
channel.exec_command(cmd)
# 读取输出
out = b""
while True:
if channel.recv_ready():
out += channel.recv(4096)
if channel.exit_status_ready():
break
time.sleep(0.5)
while channel.recv_ready():
out += channel.recv(4096)
return out.decode("utf-8", errors="replace")
# 1. 检查容器状态
print(shell(f"echo {NAS_PASS} | sudo -S {DOCKER_BIN} ps -a"))
# 2. 检查后端是否在运行
print(shell(f"echo {NAS_PASS} | sudo -S {DOCKER_BIN} ps | grep backend"))
# 3. 启动后端并查看日志
print(shell(f"cd {NAS_DEPLOY_PATH} && echo {NAS_PASS} | sudo -S {DOCKER_BIN} compose logs backend 2>&1 | tail -30"))
c.close()