05635b76b9
状态: - 9 个 sync task(stock_basic / kline_daily / kline_index / kline_5min / moneyflow / industry_sector / sector_features / share_snapshot / market_regime) - 数据源:baostock + mairui + 雪球(pysnowball) + 新浪(4 个) - 项目级约束:永远不用 akshare(已落实) - kline_5min 改用 DB 快照统一全量/增量逻辑 - 零后端 Chrome 扩展 xueqiu_sync(独立项目)
74 lines
2.4 KiB
Bash
Executable File
74 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# 串行跑所有 6 个同步任务,后台模式,写到 logs/
|
|
# 用法:./run_all_sync.sh [STEP]
|
|
# STEP 为空 = 跑 1-6
|
|
# STEP=1 只跑 stock_basic,等等
|
|
|
|
set -e
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
cd "$PROJECT_DIR"
|
|
|
|
mkdir -p logs
|
|
LOG_DIR="$PROJECT_DIR/logs"
|
|
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
|
RUN_LOG="$LOG_DIR/run_all_$TIMESTAMP.log"
|
|
|
|
# 读 token
|
|
if [ -f "$PROJECT_DIR/.env" ]; then
|
|
set -a
|
|
source "$PROJECT_DIR/.env"
|
|
set +a
|
|
fi
|
|
|
|
# 把 .env 里的 TRADING_HOLIDAYS 转成 -- 跳过
|
|
# XUEQIU_TOKEN 在 .env 里
|
|
|
|
source .venv/bin/activate
|
|
export PYTHONPATH="$PROJECT_DIR"
|
|
|
|
LOG_PREFIX="[$TIMESTAMP]"
|
|
|
|
run_step() {
|
|
local step_name="$1"
|
|
local task_id="$2"
|
|
local extra_args="$3"
|
|
local step_log="$LOG_DIR/step_${step_name}_$TIMESTAMP.log"
|
|
|
|
echo "$LOG_PREFIX === Step $step_name: $task_id ===" | tee -a "$RUN_LOG"
|
|
echo "$LOG_PREFIX log: $step_log" | tee -a "$RUN_LOG"
|
|
|
|
# 跑任务(前台模式,方便顺序执行 + 立即看到结果)
|
|
python -m app.entrypoints.cli sync "$task_id" $extra_args 2>&1 | tee "$step_log" | tail -10
|
|
local exit_code=${PIPESTATUS[0]}
|
|
|
|
if [ $exit_code -eq 0 ]; then
|
|
echo "$LOG_PREFIX ✓ Step $step_name OK" | tee -a "$RUN_LOG"
|
|
else
|
|
echo "$LOG_PREFIX ✗ Step $step_name FAIL (exit=$exit_code)" | tee -a "$RUN_LOG"
|
|
return $exit_code
|
|
fi
|
|
}
|
|
|
|
case "${1:-all}" in
|
|
1|stock_basic) run_step "1_stock_basic" "stock_basic" ;;
|
|
2|industry_sector) run_step "2_industry_sector" "industry_sector" ;;
|
|
3|kline_index) run_step "3_kline_index" "kline_index" ;;
|
|
4|kline_daily) run_step "4_kline_daily" "kline_daily" "--workers 20" ;;
|
|
5|share_snapshot) run_step "5_share_snapshot" "share_snapshot" "--workers 10" ;;
|
|
6|market_regime) run_step "6_market_regime" "market_regime" ;;
|
|
all)
|
|
run_step "1_stock_basic" "stock_basic" || exit 1
|
|
run_step "2_industry_sector" "industry_sector" || exit 1
|
|
run_step "3_kline_index" "kline_index" || exit 1
|
|
run_step "4_kline_daily" "kline_daily" "--workers 20" || exit 1
|
|
run_step "5_share_snapshot" "share_snapshot" "--workers 10" || exit 1
|
|
run_step "6_market_regime" "market_regime" || exit 1
|
|
echo "$LOG_PREFIX ✓ 全部 6 步完成" | tee -a "$RUN_LOG"
|
|
;;
|
|
*)
|
|
echo "usage: $0 [1|2|3|4|5|6|all]"
|
|
exit 1
|
|
;;
|
|
esac
|