Files
intl_news/scripts/domestic_full.sh
T
simon 3b44f64f66 refactor: 清理历史 AI Agent 文档残留 + 重构 docs/ + Pipeline 健壮性修复
- docs: 删除 CLAUDE.md / continuation.md / english-news-plan.md 及旧版 intlnews_usage.*,
        统一迁移到 docs/{README,architecture,quickstart,usage,pipeline,configuration,deployment,development,faq}.md
- README: 精简为仓库入口,指向 docs/
- configs/sources.yaml: 更新注释指向新文档
- .env.example: 修正 DashScope Embedding 端点说明

Pipeline 修复:
- dedup/llm/embedding/vectorstore/reporter: 过滤 M2 no_content / 空正文,避免污染下游与 Qdrant
- dedup/pipeline: 改为先写唯一文件再写指纹,避免崩溃导致文章永久丢失
- crawler/orchestrator: sources_crawled 改为“尝试数”,成功数 = crawled - failed
- crawler/storage: write_index_jsonl 从文章路径推断日期,修复跨天/测试路径问题
- scheduler/pipeline: STEP_TIMEOUTS 实际生效(SIGALRM)
- scheduler/reporter: emb_count 排除 index.json;日报跳过无原文事件
- vectorstore/pipeline: payload 增加 source_ids;--recreate --all 时空日期也重建 collection
- app/cli: extract/dedup/translate/embed/index/pipeline 支持 --date;embed/index 支持 --all;crawl 全源失败返回非零
- scripts: domestic_full/crawl_8g/crawl_2g/pipeline 安全加载 .env;M1 全失败不标记且最终退出码=1
2026-08-22 20:47:53 +08:00

79 lines
2.7 KiB
Bash
Executable File
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.
#!/bin/bash
# =============================================
# 国内服务器:全流程自动化(独立运行,无需海外)
# 1. M1 Pi 抓取(headful Playwright + HTTP 代理)
# 2. 全链路 M2→M6(含日报)
# =============================================
# 每天 06:00 / 12:00 / 18:00 / 22:00 各执行一次
# =============================================
# 用法:
# ./scripts/domestic_full.sh # 全新执行
# ./scripts/domestic_full.sh --resume # 从中断处继续(跳过已完成步骤,
# # 步骤状态见 data/run_state/{date}.state)
# =============================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_DIR"
# ── 参数解析 ──
RESUME=0
for arg in "$@"; do
case "$arg" in
--resume) RESUME=1 ;;
*) echo "未知参数: ${arg}(支持 --resume)" >&2; exit 1 ;;
esac
done
source "$SCRIPT_DIR/_step_state.sh"
LOG() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"; }
# ── 全流程日志:所有输出实时显示到终端,同时完整写入日志文件 ──
LOG_DIR="logs"
mkdir -p "$LOG_DIR"
FULL_LOG="$LOG_DIR/domestic_full_$(date +%Y%m%d_%H%M%S).log"
: > "$FULL_LOG"
LOG "══════ 国内全流程开始(resume=${RESUME})═══════"
LOG "全流程日志: ${FULL_LOG}(终端实时显示完整进度)"
# ── 加载 .env ──
if [ -f .env ]; then
set -a
. ./.env
set +a
fi
# ── 1. M1 Pi 抓取(headful Playwright + HTTP 代理)──
# 部分源抓取失败不阻塞管道(原语义);抓取本身按 URL 去重(index.jsonl),
# 已抓取过的 URL 不会重复写入;输出实时显示每源进度
# 只有 M1 脚本成功退出(即不是“全部源失败”)才标记完成;
# 若全部源失败,不标记,--resume 可重新抓取。
M1_FAILED=0
if step_should_run M1_crawl; then
LOG "━━━ [1/2] M1 抓取(headful Playwright + HTTP 代理)━━━"
if bash "$SCRIPT_DIR/domestic_crawl_8g.sh" 2>&1 | tee -a "$FULL_LOG"; then
step_mark M1_crawl
else
LOG "WARNING: M1 抓取未完全成功,本次不标记 M1_crawl,--resume 可重试"
M1_FAILED=1
fi
fi
# ── 2. M2→M6 管道(含日报)──
LOG "━━━ [2/2] M2→M6 管道 + 日报 ━━━"
if [ "$RESUME" = "1" ]; then
bash "$SCRIPT_DIR/pipeline.sh" --resume 2>&1 | tee -a "$FULL_LOG"
else
bash "$SCRIPT_DIR/pipeline.sh" 2>&1 | tee -a "$FULL_LOG"
fi
if [ "$M1_FAILED" -eq 1 ]; then
LOG "⚠️ 全流程结束,但 M1 抓取未成功,退出码=1"
exit 1
fi
LOG "══════ 国内全流程完成 ✅ ══════"