gao
|
46ddf8e171
|
feat: bin/systemd_deploy.sh 一键部署脚本
work #05 (2026-07-03):Stop hook 反馈 work #04 结尾'目标达成'是错的
预测,不是现状。timer/service 没真的跑 = 数据没真的进 PG。
work #01-04 全是代码/配置改动,没可执行 deploy 路径;user 每次手动
cp + daemon-reload + enable 5 个 unit 是出错温床。
修复:写 bin/systemd_deploy.sh,必须 sudo 跑,幂等,显示 plan → 等
用户确认 → 执行(拷贝 + 删孤儿 + reload + enable 新 timer + 验证)。
下一步:user 跑 sudo bash bin/systemd_deploy.sh 真把 unit 部署到
/etc,daily_check drift 才能归零,sync 目标才进入可观察达成路径。
重要:脚本就绪 ≠ 目标达成;脚本是必要非充分条件。
Co-Authored-By: Claude <noreply@anthropic.com>
|
2026-07-03 11:44:33 +08:00 |
|
gao
|
cf45f98a8a
|
feat(daily_check): systemd unit drift 自动检测
work #04 (2026-07-03):user 重申 sync 目标强调 timer/service/依赖/编码格式
全链路审计,发现 5 处 systemd unit drift:work #01 (4h timeout) 和 work #02
(morning.timer) 代码改了但没 cp 到 /etc/systemd/system/,等于没修。
根因:deployment 与 repo 各自演进无任何告警机制。
修复:在 daily_sync_check 加 _check_systemd_drift() 段,对比
bin/systemd/ 与 /etc/systemd/system/ 下所有 market-sync* unit:
- missing_in_etc (未部署) → status=not_deployed
- drifted (两边有但内容不一致, SHA256 比对) → status=drifted
- orphan_in_etc (/etc 有 repo 没维护, 捕获僵尸 unit) → status=orphan
drift 合入 alerts 让 webhook 也带;report schema_version 1→2。
立即验证:跑 daily_check 抓到 5 处 drift(4 未部署 + 1 内容不一致),
status=warning 让 webhook 自动发出——以后任何 deployment drift 都逃不掉。
Co-Authored-By: Claude <noreply@anthropic.com>
|
2026-07-03 11:37:21 +08:00 |
|
gao
|
b1ab10b952
|
chore: 清理 dataset_registry 中 6 个 MySQL/SQLite-era 旧 task 行
work #03 (2026-07-03):daily_check 报告 18 行里有 6 个 disabled 旧 task
(stock_info/kline/hs300/industry/sector/scoring),占 1/3 噪音,干扰
对真正 missed 任务的注意力。
根因:PG 迁移(commit 7a985dd)时把它们 enabled=0 标记禁用但没删行。
旧 sync_script 全部指向 dashboard/api/services/sync/*.py(sibling 项目
已下线),storage_uri 指向 dashboard/data_uat/ 下的 SQLite/Parquet。
变更:
- bin/archive/clean_legacy_registry_rows.py: 一次性清理脚本,保守策略
(enabled=0 + 旧 storage_layer 或非 app.tasks. 路径),默认 dry-run,
显式 --apply 才 DELETE
- 实际删除 6 行:stock_info / kline / hs300 / industry / sector / scoring
- docs/works/2026-07-03-03-clean-legacy-registry.md: 完整 work 记录
(含保守原则说明:enabled=0 但 storage_layer='pg' 的行不在清理范围)
验证:daily_check counts 从 18 行 → 12 行,disabled 段清零。
Co-Authored-By: Claude <noreply@anthropic.com>
|
2026-07-03 10:54:06 +08:00 |
|
gao
|
d140fee9e7
|
fix: 早盘前 09:00 stock_basic + industry_sector 没触发
work #02 (2026-07-03):daily_check 复跑仍 10 missed,细看时间窗口发现
新问题——09:00 / 09:30 该跑的 2 个早盘前 task today 没触发。
根因:worker.py 进程内 scheduler 是预期的主调度(含 09:00 / 09:30),
但 worker.py 没人拉起;systemd timers 又只覆盖 15:30 / 21:xx,缺早盘档。
昨 18h 删 monitor 同时没补 worker.py → 早盘缺口暴露。
变更:
- bin/market_sync_morning_run.sh: 轻量 morning wrapper,只跑 stock_basic
+ industry_sector 串行(~25min),不复用 runall_once.py 的 8 task
- bin/systemd/market-sync-morning.{service,timer}: Mon..Fri 09:00 daily
触发,TimeoutStartSec=3600 (1h)
- docs/works/2026-07-03-02-morning-no-trigger.md: 完整 work 记录
不在本 work 范围(更大重构):把 worker.py 拉起作为 long-running,
与 systemd timer 收敛到单一调度器——见 dual-scheduler-overlap memory。
Co-Authored-By: Claude <noreply@anthropic.com>
|
2026-07-03 10:50:25 +08:00 |
|
gao
|
295177027f
|
fix: market-sync 2h timeout 截断 + 加 daily-check 巡检
work #01 (2026-07-03):昨天 15:30 runall 中 kline_5min 全量 69min 把 2h
窗口吃满,share_snapshot / market_regime 被 systemd SIGTERM 截断;
今天又叠加 worker.py 未长驻,导致 10 个 task missed。
变更:
- bin/systemd/market-sync.service: TimeoutStartSec 7200 → 14400 (4h)
- bin/daily_sync_check.py: 新增每日巡检,读 PG dataset_registry,
对比 SCHEDULE 判定 ok/missed/failed/stuck/never_run,写 JSON 报告,
失败时 POST HMAC webhook
- bin/systemd/market-sync-daily-check.{service,timer}: 23:00 daily 触发
daily_check(替代 session-only 的 /loop 方案)
- config/daily_check_secrets.env.template: webhook 配置模板
- docs/works/2026-07-03-01-market-sync-timeout.md: 完整 work 记录
(根因 + 中期/长期改进建议)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2026-07-03 10:48:20 +08:00 |
|