chore: baseline — ORM migration + systemd deploy + MCP server + daily check
- ORM migration: models/ops 重构 - deploy: 标准化 systemd timer/service 部署体系 - MCP server: 5 个只读工具(任务/状态/数据集) - daily check: 数据一致性巡检 - watch: task_watch 后台监控 - kline_daily: 麦蕊优先,时间门禁15:00 - 删除: task_industry_sector, task_sector_features
This commit is contained in:
+33
-62
@@ -1,81 +1,52 @@
|
||||
#!/bin/bash
|
||||
# 串行跑所有 6 个同步任务,后台模式,写到 logs/
|
||||
# 用法:./run_all_sync.sh [STEP]
|
||||
# STEP 为空 = 跑 1-6
|
||||
# STEP=1 只跑 stock_basic,等等
|
||||
set -u
|
||||
|
||||
set -e
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
cd "$PROJECT_DIR"
|
||||
PROJECT_ROOT="/home/gao/Development/quant_home/market_sync"
|
||||
LOG_DIR="$PROJECT_ROOT/logs"
|
||||
RUN_LOG="$LOG_DIR/run_all_sync_$(date +%Y%m%d_%H%M%S).log"
|
||||
|
||||
mkdir -p logs
|
||||
LOG_DIR="$PROJECT_DIR/logs"
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
RUN_LOG="$LOG_DIR/run_all_$TIMESTAMP.log"
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
# 读 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]"
|
||||
LOG_PREFIX="[run_all_sync]"
|
||||
|
||||
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"
|
||||
local step=$1 task=$2 extra_args=${3:-}
|
||||
echo "$LOG_PREFIX === 步骤 $step: $task ===" | tee -a "$RUN_LOG"
|
||||
if [ -n "$extra_args" ]; then
|
||||
.venv/bin/python -m app.entrypoints.cli sync "$task" $extra_args 2>&1 | tee -a "$RUN_LOG"
|
||||
else
|
||||
echo "$LOG_PREFIX ✗ Step $step_name FAIL (exit=$exit_code)" | tee -a "$RUN_LOG"
|
||||
return $exit_code
|
||||
.venv/bin/python -m app.entrypoints.cli sync "$task" 2>&1 | tee -a "$RUN_LOG"
|
||||
fi
|
||||
local rc=${PIPESTATUS[0]}
|
||||
if [ $rc -ne 0 ]; then
|
||||
echo "$LOG_PREFIX ✗ 步骤 $step ($task) 失败 (exit=$rc)" | tee -a "$RUN_LOG"
|
||||
return $rc
|
||||
fi
|
||||
echo "$LOG_PREFIX ✓ 步骤 $step ($task) 完成" | tee -a "$RUN_LOG"
|
||||
}
|
||||
|
||||
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" ;;
|
||||
7|kline_5min) run_step "7_kline_5min" "kline_5min" "--workers 10" ;;
|
||||
8|moneyflow) run_step "8_moneyflow" "moneyflow" "--workers 10" ;;
|
||||
9|sector_features) run_step "9_sector_features" "sector_features" ;;
|
||||
10|tick_trade) run_step "10_tick_trade" "tick_trade" "--workers 5 --force" ;;
|
||||
2|kline_index) run_step "2_kline_index" "kline_index" ;;
|
||||
3|kline_daily) run_step "3_kline_daily" "kline_daily" "--workers 20" ;;
|
||||
4|share_snapshot) run_step "4_share_snapshot" "share_snapshot" "--workers 10" ;;
|
||||
5|market_regime) run_step "5_market_regime" "market_regime" ;;
|
||||
6|kline_5min) run_step "6_kline_5min" "kline_5min" "--workers 10" ;;
|
||||
7|moneyflow) run_step "7_moneyflow" "moneyflow" "--workers 10" ;;
|
||||
8|tick_trade) run_step "8_tick_trade" "tick_trade" "--workers 5 --force" ;;
|
||||
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
|
||||
run_step "7_kline_5min" "kline_5min" "--workers 10" || exit 1
|
||||
run_step "8_moneyflow" "moneyflow" "--workers 10" || exit 1
|
||||
run_step "9_sector_features" "sector_features" || exit 1
|
||||
run_step "10_tick_trade" "tick_trade" "--workers 5 --force" || exit 1
|
||||
echo "$LOG_PREFIX ✓ 全部 10 步完成" | tee -a "$RUN_LOG"
|
||||
run_step "2_kline_index" "kline_index" || exit 1
|
||||
run_step "3_kline_daily" "kline_daily" "--workers 20" || exit 1
|
||||
run_step "4_share_snapshot" "share_snapshot" "--workers 10" || exit 1
|
||||
run_step "5_market_regime" "market_regime" || exit 1
|
||||
run_step "6_kline_5min" "kline_5min" "--workers 10" || exit 1
|
||||
run_step "7_moneyflow" "moneyflow" "--workers 10" || exit 1
|
||||
run_step "8_tick_trade" "tick_trade" "--workers 5 --force" || exit 1
|
||||
echo "$LOG_PREFIX ✓ 全部 8 步完成" | tee -a "$RUN_LOG"
|
||||
;;
|
||||
*)
|
||||
echo "usage: $0 [1|2|3|4|5|6|7|8|9|10|all]"
|
||||
echo "usage: $0 [1|2|3|4|5|6|7|8|all]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user