# tradingSystem (PMS) 常用操作一句话入口 # ============================================================================ # 为什么要这个文件: 日常命令都是「docker compose run --rm --no-deps pms-web python # scripts/xxx.py」这种一行八十字符的东西, 手打容易漏 --no-deps (于是顺带把 beat/worker # 也拉起来)、漏 --rm (于是攒一堆退出的容器)。把口径固定在这里, 少一类手误。 # # make help 看有哪些目标 # make deploy 拉代码 → 重建镜像 → 重建容器 → 建表 (= scripts/deploy.sh) # make test 跑全部单测 (不连库, 秒级) # # **改了 Python 代码必须 build + force-recreate**, 因为源码是打进镜像的 —— # `docker compose restart` 跑的还是旧镜像里的旧代码, 而且一点报错都没有 (deploy.sh # 头部有详细说明)。`make up` 用的就是这条路径, 别用 `docker compose restart` 代替。 # ============================================================================ .DEFAULT_GOAL := help SHELL := /bin/bash # 各 profile 的组合。只想跑页面: `make up PROFILES=` PROFILES ?= --profile sched --profile ws DC := docker compose $(PROFILES) # 一次性命令一律 --no-deps: 不然跑个单测都会把 beat/worker 拉起来 RUN := docker compose run --rm --no-deps pms-web .PHONY: help deploy deploy-local build up down ps logs test initdb check health \ probe changes industry ws-status reset-ledger shell help: ## 列出所有目标 @grep -hE '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-14s\033[0m %s\n", $$1, $$2}' # ---------------------------------------------------------------- 部署 deploy: ## 一句话部署: git pull → build → up --force-recreate → 建表 @./scripts/deploy.sh deploy-local: ## 同 deploy 但跳过 git pull (本地已改好) @./scripts/deploy.sh --no-pull build: ## 只重建镜像 $(DC) build up: ## 起服务 (force-recreate —— 让新镜像真正生效) $(DC) up -d --force-recreate @$(DC) ps down: ## 停掉全部服务 (不删卷) $(DC) down ps: ## 看服务状态 @$(DC) ps logs: ## 跟日志 (make logs S=pms-ws 只看一个服务) $(DC) logs -f $(S) # ---------------------------------------------------------------- 自检 test: ## 全部单测 (零外部依赖, 不连库; 应输出 ALL SUITES PASS) $(RUN) python scripts/run_tests.py initdb: ## 建表/补表 (幂等; 加 DRY=1 只演练打印) $(RUN) python scripts/init_db.py $(if $(DRY),,--yes) check: ## 实机连通性与表结构自检 (需真实 .env) $(RUN) python scripts/check_db.py health: ## 页面健康检查 (配置装载 + 库连通自证) @curl -s http://127.0.0.1:38100/health | python3 -m json.tool # ---------------------------------------------------------------- 上游 / 行业 / 通道 probe: ## 上游计划实机探活 (只读; 加 SNAP=1 顺带落一份名册快照) $(RUN) python scripts/probe_plan_api.py $(if $(SNAP),--snapshot,) changes: ## 榜单变化: 谁新进谁掉榜、持仓票有没有被上游摘了 @curl -s 'http://127.0.0.1:38100/api/upstream/plan-changes?limit=30' \ | python3 -m json.tool industry: ## 行业源实探 (ready=false 就是硬拦截失效, 别当它绿着) @curl -s http://127.0.0.1:38100/api/industry | python3 -m json.tool ws-status: ## ws 通道状态 (连接态 / seq 水位 / 出口队列) $(RUN) python scripts/ws_smoke.py status # ---------------------------------------------------------------- 危险操作 (要确认) reset-ledger: ## 清空账本重来 (影子期专用; 必须 CONFIRM=1) @if [ "$(CONFIRM)" != "1" ]; then \ echo "这会清空 PMS 账本。确认请加 CONFIRM=1, 例如:"; \ echo " make reset-ledger CONFIRM=1 ARGS='--purge-channel --reset-ws'"; exit 1; fi $(RUN) python scripts/reset_ledger.py --yes $(ARGS) shell: ## 进容器 (排查用) docker compose run --rm --no-deps pms-web bash