Files
intl_news/scripts/domestic_full.sh
T
simon 06b00b7f49 feat: 全流程脚本 --resume 断点续跑 + 各步骤文件级增量说明
- 新增 scripts/_step_state.sh:步骤状态库(data/run_state/{date}.state,按天换新)
- pipeline.sh / domestic_full.sh 支持 --resume,按步骤跳过已完成项
- step_run 显式检查退出码(规避 bash set -e 条件上下文陷阱),失败步骤不标记
- M1 保持部分源失败容忍(step_should_run/step_mark 手动控制)
- 确认并文档化各步骤文件级增量:M2/M4/M5 按文件存在跳过、M3 指纹库、M6 upsert 幂等
- 已同步 pi5 并验证(--badarg exit=1、step_run 机制正常)
2026-08-12 11:06:29 +08:00

56 lines
2.0 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 "══════ 国内全流程开始(resume=${RESUME})═══════"
# ── 加载 .env ──
export $(grep -v '^#' .env | grep -v '^$' | xargs 2>/dev/null || true)
# ── 1. M1 Pi 抓取(headful Playwright + HTTP 代理)──
# 部分源抓取失败不阻塞管道(原语义);抓取本身按 URL 去重(index.jsonl),
# 已抓取过的 URL 不会重复写入
if step_should_run M1_crawl; then
LOG "[1/2] Pi M1 抓取(8G headful + HTTP 代理)..."
bash "$SCRIPT_DIR/domestic_crawl_8g.sh" 2>&1 | tail -5 || LOG "WARNING: 部分源抓取失败,继续管道"
step_mark M1_crawl
fi
# ── 2. M2→M6 管道(含日报)──
LOG "[2/2] 全链路管道..."
if [ "$RESUME" = "1" ]; then
bash "$SCRIPT_DIR/pipeline.sh" --resume 2>&1 | tail -10
else
bash "$SCRIPT_DIR/pipeline.sh" 2>&1 | tail -10
fi
LOG "══════ 国内全流程完成 ✅ ══════"