foms/README.md
yumoqing dedb7bfc57 refactor: foms 改为纯业务模块,应用层迁至纯伞仓 foms_app
foms 只保留业务逻辑:
  · foms/ 包(init.py + failover.py 切换编排器)
  · models/(5 张表)、json/(CRUD 定义)、wwwroot/api/(端点)
  · scripts/(foms-agent 及部署脚本)
  · docs/deploy-operations.md

应用层迁出至 foms_app 纯伞仓:
  · app/(入口)、build.sh、start/stop.sh、conf/、init/data.yaml
  · scripts/init_rbac.py / load_path.py(重写为新 URL 布局)
  · wwwroot/index.ui(重写,指向各模块前缀路径)

同时修复 foms/__init__.py:移除对拆分时已删除函数的导出。
2026-08-27 11:07:37 +08:00

42 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# foms — 主备切换核心模块
FOMS 的**领域核心**(业务逻辑层),独立可安装模块。
应用壳(构建/配置/启动/首页)在纯伞仓 **foms_app**
## 内容
| 部分 | 文件 | 说明 |
|---|---|---|
| 包入口 | `foms/init.py` | 集群/节点 CRUD、心跳、仪表盘、远程命令队列、`load_foms()` |
| 切换编排器 | `foms/failover.py` | 六步状态机 + 逆向回滚 + 防脑裂 + 健康判定器 |
| 表定义 | `models/*.json` | clusters、nodes、switchover_logs、switchover_steps、node_commands |
| CRUD 定义 | `json/*.json` | clusters_list、nodes_list |
| 端点 | `wwwroot/api/*.dspy` | 心跳、命令、切换、仪表盘等 |
| Agent | `scripts/foms-agent.py` | 被管主机守护进程(独立部署,非本包代码) |
| 运维文档 | `docs/deploy-operations.md` | 部署 + 运维手册 |
## 切换闭环2026-08-26 补全)
健康判定器(防抖告警,半自动)→ 人工确认 → 六步状态机:
```
precheck → fence → promote → flip_sync → verify → converge
```
失败逆向回滚防脑裂不变量fence 先于 promotefence 失败硬中止。
详见 `docs/deploy-operations.md`
## 安装
```bash
pip install -e .
```
由 foms_app 的 build.sh 统一组装。`load_foms()` 时自动注册切换编排器
并拉起健康判定器后台任务(幂等)。
## 邻接模块(独立仓库)
- dbbackup — 数据库备份 + 日志同步binlog 复制)
- filesync — 运行文件同步rsync
- hostwatch — 日志监控 + 日志分析 + 主机指标
仪表盘对这三模块的表做同库只读聚合(松耦合)。