# Momentry Core 快速参考卡片 ## 🚀 快速启动 ```bash # 启动所有服务(一键启动) ./scripts/start_all_services.sh # 查看状态 ./scripts/check_status.sh # 停止服务 ./scripts/stop_all_services.sh ``` --- ## 📋 手动启动命令 ### 方式 1: launchd(生产环境,推荐) ```bash # 启动 launchctl start gui/$(id -u)/com.momentry.server # 停止 launchctl stop gui/$(id -u)/com.momentry.server # 查看状态 launchctl list | grep momentry ``` ### 方式 2: 手动启动 ```bash # Release 模式(生产) cargo run --release -- server --port 3002 # Debug 模式(开发) cargo run -- server --port 3002 # 后台运行 ./target/release/momentry server > logs/momentry_3002.log 2>&1 & ``` --- ## 🔍 常用命令 ### 日志查看 ```bash # 实时查看日志 tail -f logs/momentry_3002.log # 查看最近错误 grep -i "error\|panic" logs/momentry_3002.log | tail -20 # 查看特定模块日志 grep -i "vlm" logs/momentry_3002.log | tail -20 grep -i "command_queue" logs/momentry_3002.log | tail -20 ``` ### 队列状态 ```bash # VLM 队列状态 curl http://localhost:3002/api/v1/vlm/queue/status \ -H "Authorization: Bearer $API_KEY" | jq # 数据库队列状态 psql -U accusys -d momentry -c " SELECT status, COUNT(*) FROM command_queue GROUP BY status " # VLM 队列状态 psql -U accusys -d momentry -c " SELECT status, COUNT(*) FROM vlm_requests GROUP BY status " ``` ### 服务检查 ```bash # 检查 API curl http://localhost:3002/api/v1/health # 检查 LLM curl http://localhost:8080/v1/models # 检查数据库 psql -U accusys -d momentry -c "SELECT 1" # 检查 Redis redis-cli ping ``` --- ## 🛠️ 故障排除 ### 服务无响应 ```bash # 1. 检查进程 ps aux | grep momentry # 2. 检查端口 lsof -i :3002 # 3. 重启服务 pkill -f "momentry server" sleep 2 ./scripts/start_all_services.sh ``` ### VLM 队列卡住 ```bash # 1. 检查 VLM 服务 curl http://localhost:8080/v1/models # 2. 查看队列状态 psql -U accusys -d momentry -c " SELECT id, status, request_type, created_at FROM vlm_requests WHERE status IN ('pending', 'processing') ORDER BY created_at DESC LIMIT 10 " # 3. 重置卡住的请求(谨慎使用) # psql -U accusys -d momentry -c " # UPDATE vlm_requests # SET status = 'timeout', error = 'Manually reset' # WHERE status = 'processing' AND started_at < NOW() - INTERVAL '1 hour' # " ``` ### 数据库连接失败 ```bash # 检查 PostgreSQL brew services list | grep postgresql # 启动 PostgreSQL brew services start postgresql@14 # 测试连接 psql -U accusys -d momentry -c "SELECT version()" ``` --- ## 📊 性能监控 ### CPU/内存使用 ```bash # macOS top -pid $(pgrep -f "momentry server") # 或使用 Activity Monitor ``` ### GPU 使用 ```bash # macOS: 使用 Activity Monitor # 查看 "GPU" 标签页 # Linux nvidia-smi ``` ### 磁盘使用 ```bash # 输出目录 du -sh /Users/accusys/momentry/output # 日志目录 du -sh logs/ # 数据库大小 psql -U accusys -d momentry -c " SELECT pg_size_pretty(pg_database_size('momentry')) " ``` --- ## 🔧 配置修改 ### 修改并发数 ```bash # 编辑 .env vim .env # 修改以下变量 MOMENTRY_MAX_CONCURRENT=6 MOMENTRY_VLM_MAX_CONCURRENT=3 # 重启服务 ./scripts/stop_all_services.sh ./scripts/start_all_services.sh ``` ### 修改 VLM 超时 ```bash # 编辑 .env MOMENTRY_VLM_TIMEOUT_SECONDS=60 # 重启服务 ``` --- ## 📝 常用环境变量 | 变量 | 默认值 | 说明 | |------|--------|------| | `MOMENTRY_SERVER_PORT` | 3002 | API 端口 | | `MOMENTRY_MAX_CONCURRENT` | 6 | 最大并发任务数 | | `MOMENTRY_VLM_MAX_CONCURRENT` | 3 | VLM 最大并发数 | | `MOMENTRY_VLM_TIMEOUT_SECONDS` | 60 | VLM 超时时间 | | `MOMENTRY_OUTPUT_DIR` | /Users/accusys/momentry/output | 输出目录 | | `DATABASE_URL` | postgres://accusys@localhost:5432/momentry | 数据库连接 | --- ## 🆘 紧急命令 ```bash # 强制停止所有 Momentry 进程 pkill -9 -f momentry # 清理日志(释放磁盘空间) rm -f logs/*.log # 重置队列(危险操作!) # psql -U accusys -d momentry -c "DELETE FROM vlm_requests WHERE status = 'pending'" # psql -U accusys -d momentry -c "DELETE FROM command_queue WHERE status = 'pending'" # 重启所有服务 ./scripts/stop_all_services.sh && sleep 5 && ./scripts/start_all_services.sh ``` --- ## 📚 相关文档 - 架构说明: `docs_v1.0/OPERATIONS/QUEUE_SYSTEM_ARCHITECTURE.md` - VLM 队列设计: `docs_v1.0/DESIGN/VLM_Queue_Design.md` - 部署指南: `docs_v1.0/OPERATIONS/DELIVERY_PROCEDURE.md` - 故障排除: `docs_v1.0/OPERATIONS/TROUBLESHOOTING.md` --- **保存此文件以便快速参考!**