Files
gao 05635b76b9 chore: 重构前基线 — 9 个 sync task 全部 ok + akshare 移除 + mairui 资金流接入
状态:
- 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(独立项目)
2026-06-15 15:36:09 +08:00

73 lines
2.2 KiB
Bash
Executable File
Raw Permalink 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
# market_data_sync 启动脚本
# 用法:./start.sh 启动 API(默认端口 8100)
# ./start.sh worker 仅启动调度器 + 同步 worker(无 web
# ./start.sh sync <task_id> 手动执行一次同步任务
# ./start.sh status 查看调度器 / 数据源 / 同步任务状态
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
# ---- venv ----
VENV_DIR="$SCRIPT_DIR/.venv"
if [ ! -d "$VENV_DIR" ]; then
echo "[market_data_sync] creating venv ..."
python3 -m venv "$VENV_DIR"
fi
source "$VENV_DIR/bin/activate"
# ---- deps ----
if [ ! -f "$VENV_DIR/.deps_installed" ] || [ requirements.txt -nt "$VENV_DIR/.deps_installed" ]; then
echo "[market_data_sync] installing deps ..."
pip install --upgrade pip -q
pip install -r requirements.txt -q
touch "$VENV_DIR/.deps_installed"
fi
# ---- .env ----
if [ ! -f "$SCRIPT_DIR/.env" ]; then
echo "[market_data_sync] no .env found, copying .env.example"
cp "$SCRIPT_DIR/.env.example" "$SCRIPT_DIR/.env"
echo "[market_data_sync] ⚠️ please edit .env with your real MySQL credentials before continuing"
fi
# ---- export PYTHONPATH ----
export PYTHONPATH="$SCRIPT_DIR${PYTHONPATH:+:$PYTHONPATH}"
# ---- ensure logs dir ----
mkdir -p "$SCRIPT_DIR/logs"
# ---- dispatch ----
MODE="${1:-api}"
case "$MODE" in
api)
PORT="${API_PORT:-8100}"
HOST="${API_HOST:-0.0.0.0}"
echo "[market_data_sync] starting API on $HOST:$PORT"
exec uvicorn app.api.main:app --host "$HOST" --port "$PORT" --log-level info
;;
worker)
echo "[market_data_sync] starting scheduler worker (no web)"
exec python -m app.entrypoints.worker
;;
sync)
TASK_ID="${2:?usage: ./start.sh sync <task_id>}"
echo "[market_data_sync] manual sync: $TASK_ID"
exec python -m app.entrypoints.cli sync "$TASK_ID"
;;
status)
exec python -m app.entrypoints.cli status
;;
list)
exec python -m app.entrypoints.cli list
;;
datasources)
exec python -m app.entrypoints.cli datasources
;;
*)
echo "usage: $0 {api|worker|sync <task_id>|status|list|datasources}"
exit 1
;;
esac