d140fee9e7
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>
46 lines
1.7 KiB
Bash
Executable File
46 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
||
# 早盘前同步:stock_basic + industry_sector
|
||
# - stock_basic:雪球 quote_detail 拉全市场股本快照(~9min @ 5 RPS)
|
||
# - industry_sector:baostock 拉股票-行业映射(~16min @ 5 RPS)
|
||
# - 串行执行,industry_sector 依赖 stock_basic
|
||
# - 与 runall_once.py 区别:不拉 kline_daily / kline_5min 等耗时长任务
|
||
|
||
set -u
|
||
|
||
PROJECT_ROOT="/home/gao/Development/quant_home/market_sync"
|
||
LOG_DIR="$PROJECT_ROOT/logs"
|
||
mkdir -p "$LOG_DIR"
|
||
|
||
TS=$(date +%Y%m%d_%H%M%S)
|
||
LOG="$LOG_DIR/morning_run_${TS}.log"
|
||
|
||
cd "$PROJECT_ROOT"
|
||
exec .venv/bin/python -c "
|
||
import sys, time
|
||
sys.path.insert(0, '$PROJECT_ROOT')
|
||
|
||
from app.core.datasource.registry import build_default_registry
|
||
from app.core.sync.registry import seed_sync_registry
|
||
build_default_registry()
|
||
seed_sync_registry()
|
||
|
||
from app.tasks import get_task
|
||
|
||
results = []
|
||
for tid in ['stock_basic', 'industry_sector']:
|
||
print(f'[morning-run] >>> 开始 {tid}', flush=True)
|
||
t0 = time.time()
|
||
try:
|
||
r = get_task(tid).run(trigger_source='morning_runall')
|
||
elapsed = round(time.time() - t0, 1)
|
||
results.append({'task': tid, 'status': r.get('status'), 'elapsed_sec': elapsed, 'message': r.get('message', '')})
|
||
print(f'[morning-run] <<< {tid} status={r.get(\"status\")} elapsed={elapsed}s msg={r.get(\"message\", \"\")}', flush=True)
|
||
except Exception as e:
|
||
elapsed = round(time.time() - t0, 1)
|
||
results.append({'task': tid, 'status': 'error', 'elapsed_sec': elapsed, 'message': str(e)})
|
||
print(f'[morning-run] !!! {tid} 异常: {e}', flush=True)
|
||
time.sleep(5)
|
||
|
||
import json
|
||
print('[morning-run] summary:', json.dumps(results, ensure_ascii=False))
|
||
" > "$LOG" 2>&1 |