Files
momentry_core/scripts/check_status.sh
T
Accusys 63fbbe1225 release: v1.3.1 - Pipeline Queue Integration, OCR Fix, Worker Compatibility
Major Changes:
- Pipeline Queue integration completed (internal.file + pipeline.commands)
- Fixed old job_worker database compatibility with new command_queue table
- Compiled Swift OCR binary (was missing, causing empty OCR results)
- Added deep scan functionality through re-scan API

Fixes:
- Changed CommandJob.id from i32 to i64 for database compatibility
- Added UUID generation in create_command (message_id field)
- Fixed claim_pending_commands to query queue_name = 'internal.file'
- Fixed field mappings: command_id → message_id, job_type → command_type
- Added support for 'processing' status in CommandJobStatus

Queue System:
- internal.file queue: for register/unregister/re-scan commands (job_worker)
- pipeline.commands queue: for vectorize/store_asrx/etc commands (pipeline_worker)

Documentation:
- Added comprehensive queue system documentation
- Created M4 workspace status reports
- Updated AGENTS.md with queue system details
2026-10-12 10:00:51 +08:00

158 lines
3.9 KiB
Bash
Executable File

#!/bin/bash
# Momentry Core 状态检查脚本
# 用途:检查所有服务的运行状态
echo "===================================="
echo " Momentry Core 状态检查"
echo "===================================="
echo ""
# 加载环境变量
if [ -f .env ]; then
export $(cat .env | grep -v '^#' | xargs)
fi
# 颜色定义
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# 检查函数
check_service() {
local name=$1
local check_cmd=$2
if eval "$check_cmd" > /dev/null 2>&1; then
echo -e "${GREEN}✅${NC} $name: 运行中"
return 0
else
echo -e "${RED}❌${NC} $name: 未运行"
return 1
fi
}
# 1. 数据库服务
echo "1️⃣ 数据库服务"
echo ""
check_service "PostgreSQL" "pg_isready -q"
check_service "Redis" "redis-cli -a $REDIS_PASSWORD ping | grep PONG"
if curl -s http://localhost:6333/health 2>/dev/null | grep -q "ok"; then
echo -e "${GREEN}✅${NC} Qdrant: 运行中"
else
echo -e "${YELLOW}⚠️${NC} Qdrant: 未运行 (可选)"
fi
echo ""
# 2. LLM 服务
echo "2️⃣ LLM 服务"
echo ""
check_service "Chat/VLM (port 8080)" "curl -s http://localhost:8080/v1/models | grep gemma"
echo ""
# 3. Momentry 服务
echo "3️⃣ Momentry 服务"
echo ""
# API Server
if curl -s http://localhost:3002/api/v1/health 2>/dev/null | grep -q "ok"; then
echo -e "${GREEN}✅${NC} API Server (port 3002): 运行中"
# 检查进程信息
PID=$(pgrep -f "momentry server" | head -1)
if [ -n "$PID" ]; then
echo " PID: $PID"
echo " 内存: $(ps -o rss= -p $PID | awk '{printf "%.1f MB\n", $1/1024}')"
fi
else
echo -e "${RED}❌${NC} API Server: 未运行"
fi
echo ""
# 4. 队列状态
echo "4️⃣ 队列状态"
echo ""
# 命令队列
if [ -n "$DATABASE_URL" ]; then
PENDING=$(psql "$DATABASE_URL" -t -c "SELECT COUNT(*) FROM command_queue WHERE status='pending'" 2>/dev/null | xargs)
RUNNING=$(psql "$DATABASE_URL" -t -c "SELECT COUNT(*) FROM command_queue WHERE status='running'" 2>/dev/null | xargs)
echo "命令队列: pending=$PENDING, running=$RUNNING"
fi
# VLM 队列
if [ -n "$DATABASE_URL" ]; then
PENDING=$(psql "$DATABASE_URL" -t -c "SELECT COUNT(*) FROM vlm_requests WHERE status='pending'" 2>/dev/null | xargs)
PROCESSING=$(psql "$DATABASE_URL" -t -c "SELECT COUNT(*) FROM vlm_requests WHERE status='processing'" 2>/dev/null | xargs)
echo "VLM 队列: pending=$PENDING, processing=$PROCESSING"
fi
echo ""
# 5. 磁盘使用
echo "5️⃣ 磁盘使用"
echo ""
if [ -n "$MOMENTRY_OUTPUT_DIR" ]; then
if [ -d "$MOMENTRY_OUTPUT_DIR" ]; then
USAGE=$(du -sh "$MOMENTRY_OUTPUT_DIR" 2>/dev/null | cut -f1)
echo "输出目录: $USAGE ($MOMENTRY_OUTPUT_DIR)"
fi
fi
# 日志目录
if [ -d "logs" ]; then
LOG_USAGE=$(du -sh logs 2>/dev/null | cut -f1)
echo "日志目录: $LOG_USAGE (logs/)"
fi
echo ""
# 6. 最近错误
echo "6️⃣ 最近错误 (最近 10 条)"
echo ""
if [ -f "logs/momentry_3002.log" ]; then
ERRORS=$(grep -i "error\|panic\|FAIL" logs/momentry_3002.log | tail -10)
if [ -n "$ERRORS" ]; then
echo "$ERRORS"
else
echo "✅ 无最近错误"
fi
else
echo "⚠️ 日志文件不存在"
fi
echo ""
# 总结
echo "===================================="
echo " 状态检查完成"
echo "===================================="
echo ""
# 计算健康分数
HEALTH=0
pg_isready -q > /dev/null 2>&1 && ((HEALTH++))
redis-cli -a "$REDIS_PASSWORD" ping 2>/dev/null | grep -q PONG && ((HEALTH++))
curl -s http://localhost:8080/v1/models 2>/dev/null | grep -q "gemma" && ((HEALTH++))
curl -s http://localhost:3002/api/v1/health 2>/dev/null | grep -q "ok" && ((HEALTH++))
echo "健康分数: $HEALTH/4"
if [ $HEALTH -eq 4 ]; then
echo -e "${GREEN}✅ 系统完全健康${NC}"
elif [ $HEALTH -ge 2 ]; then
echo -e "${YELLOW}⚠️ 系统部分健康${NC}"
else
echo -e "${RED}❌ 系统不健康${NC}"
fi
echo ""