← 返回 Dashboard

常用命令速查

本项目日常运维、调试、测试命令汇总

🕷 数据抓取

cd /home/ubuntu/demand_crawler_mvp && venv/bin/python demand_crawler.py

手动执行一次完整抓取、分类、评分流程。

🤖 大模型增强处理

# 增量处理未 enrichment 的记录
venv/bin/python scripts/enrich_with_llm.py
# 全量重新处理所有记录
venv/bin/python scripts/enrich_with_llm.py --all
# 只处理最新 50 条
venv/bin/python scripts/enrich_with_llm.py --limit 50

需要先配置 LLM_API_KEYLLM_MODELLLM_ENRICH_ENABLED=1

🧪 测试

venv/bin/python -m pytest tests/ -q --ignore=tests/test_freelancer_collector.py --ignore=tests/test_llm_enrichment.py --ignore=tests/test_llm_client.py

排除外部依赖较长的测试后,快速跑完核心测试。

🖥 Dashboard 服务(由宝塔管理)

# 宝塔启动脚本(推荐在宝塔面板里操作)
sudo bash /www/server/python_project/vhost/scripts/demand_crawler_mvp_gunicorn.sh
# 查看当前进程
ps -ef | grep gunicorn | grep -v grep
# 停止服务(如需重启,先停后跑启动脚本)
pid=$(cat /www/server/python_project/vhost/pids/demand_crawler_mvp.pid); sudo kill $pid

注意:demand-dashboard.service 已停用,不再使用 systemd 管理。

⏰ Cron 定时任务

crontab -l

查看当前定时任务。抓取脚本每 2 小时执行一次。

🗄 数据库检查

# 查看最近一次抓取
venv/bin/python -c "from dashboard import queries; print(queries.get_latest_run(queries.get_repo()))"
# 手动应用迁移
venv/bin/python -c "from src.demand_intelligence.storage import DemandRepository; DemandRepository().ensure_schema()"
# 统计未 enrichment 数量
venv/bin/python -c "from src.demand_intelligence.storage import DemandRepository; r=DemandRepository(); cur=r._connect().cursor(); cur.execute('SELECT COUNT(*) FROM normalized_opportunities WHERE is_llm_enriched=false'); print(cur.fetchone()[0])"

📄 日志文件

  • 抓取日志:logs/cron.log
  • Dashboard 日志:dashboard/app.log
  • LLM 报表:output/llm_reports/

🔧 配置文件

  • 项目环境变量:.env
  • 示例环境变量:.env.example
  • 宝塔环境变量:/www/server/python_project/vhost/env/demand_crawler_mvp.env