[Unit] Description=Market Data Full Sync (PostgreSQL, 9 sync tasks end-to-end) Documentation=file:///home/gao/Development/quant_home/market_sync/bin/market_sync_run.sh After=network-online.target Wants=network-online.target [Service] Type=oneshot WorkingDirectory=/home/gao/Development/quant_home/market_sync User=gao Group=gao # 入口脚本(runall_once.py + structured_watch.sh 二合一) ExecStart=/home/gao/Development/quant_home/market_sync/bin/market_sync_run.sh # 硬上限 3h(实际 ~80min + kline_5min 增量 70min, 总 ~2.5h, 留 30min buffer) # 2026-07-08 教训: 之前 4h 让 kline_daily 单点卡死拖 4h,runall 链全部受影响。 # runall_once.py 已加 per-task multiprocessing timeout(单 task 最长 75min), # 这里 3h 是 systemd 层兜底。 TimeoutStartSec=10800 # 不要 Restart=(oneshot 失败就让 OnFailure= 发通知,别自动重跑—— # 重跑会撞外部 API 限流窗口,浪费 1.5h) # Restart=no 是 oneshot 默认值 # 日志走 journald(journalctl -u market-sync.service -f) StandardOutput=journal StandardError=journal SyslogIdentifier=market-sync # 环境(不读 /etc/environment,只带这几个;.env 由 runall_once.py 内部 load_dotenv) Environment=PYTHONUNBUFFERED=1 [Install] WantedBy=multi-user.target