diff --git a/docs/dev-spec.md b/docs/dev-spec.md index 5e5fb62..82c32b9 100644 --- a/docs/dev-spec.md +++ b/docs/dev-spec.md @@ -1,6 +1,6 @@ # 开发规范 -> 版本: v2.2 | 更新: 2026-07-17 +> 版本: v2.3 | 更新: 2026-07-19 --- @@ -14,6 +14,7 @@ 2. **部署必验** — 部署后不打开 K Tab 验证 = 部署未完成 3. **不可见即不存在** — 组件不在 dashboard 中显示 = 等于没部署。离线不告警 = 监控缺陷 4. **实现后同步 Spec** — 每轮开发完毕后,必须将 specs/{module}.json 更新为与实际实现一致的状态。文档过期 = 等于没写 +5. **部署目标即验收标准** — 所有代码必须以部署目标环境(Linux 246)为基准编写和测试。在本地开发机器(Windows/Mac)上跑通不等于验收通过。部署脚本、系统工具(`systemctl`/`crontab`/`ss`/`df`)、Python 版本、文件路径等都必须匹配 246 的实际环境。禁止使用 Windows 专属 API(`tasklist`、`netstat`、`schtasks`、`wmic`)在 246 部署的代码中 --- diff --git a/gateway/scripts/dashboard.py b/gateway/scripts/dashboard.py index ca6a1ab..05504a7 100644 --- a/gateway/scripts/dashboard.py +++ b/gateway/scripts/dashboard.py @@ -844,37 +844,16 @@ def api_monitor(): status = "error" result["tasks"].append({"name": name, "status": status}) else: - # Linux: SSH 到 Windows 查 schtasks(输出可能是 GBK) - win_host = os.environ.get("WINDOWS_HOST", "192.168.1.16") + # Linux: 直接检查本地 crontab(不在 Windows 上跑了) for name in expected_tasks: try: - r = subprocess.run( - ["ssh", "-o", "StrictHostKeyChecking=no", "-o", "ConnectTimeout=5", - "-o", "BatchMode=yes", f"hmo@{win_host}", - f"schtasks /Query /TN {name} /FO CSV /NH"], - capture_output=True, timeout=10 - ) - # 先看去重定向码:非0 = 任务不存在 - if r.returncode != 0: - result["tasks"].append({"name": name, "status": "not_deployed"}) - continue - # 尝试解码输出(Windows schtasks 默认 GBK,也试试 UTF-8) - out = "" - for enc in ["utf-8", "gbk", "gb2312", "cp936"]: - try: - out = r.stdout.decode(enc) - break - except UnicodeDecodeError: - continue - if name in out: - if "就绪" in out or "Ready" in out or "Running" in out: - result["tasks"].append({"name": name, "status": "schtasks_ok"}) - else: - result["tasks"].append({"name": name, "status": "schtasks_unknown", "raw": out.strip()}) + r = subprocess.run(["crontab", "-l"], capture_output=True, text=True, timeout=5) + if name in r.stdout: + result["tasks"].append({"name": name, "status": "cron_ok"}) else: result["tasks"].append({"name": name, "status": "not_deployed"}) except Exception as e: - result["tasks"].append({"name": name, "status": "not_deployed", "note": f"SSH到Windows失败: {str(e)[:60]}"}) + result["tasks"].append({"name": name, "status": "not_deployed", "note": str(e)[:60]}) return jsonify(result)