diff --git a/backend/apps/common/services/system_log_service.py b/backend/apps/common/services/system_log_service.py index efe2d7bd..4ac8c61f 100644 --- a/backend/apps/common/services/system_log_service.py +++ b/backend/apps/common/services/system_log_service.py @@ -91,7 +91,7 @@ class SystemLogService: raw_lines = [ln for ln in raw.splitlines() if ln.strip()] # 解析日志行,提取时间戳用于排序 - # 支持 JSON 格式日志(包含 asctime 字段) + # 支持 JSON 格式日志(包含 asctime 字段)和方括号格式 [2025-12-17 17:09:06] parsed: list[tuple[datetime | None, int, str]] = [] for idx, line in enumerate(raw_lines): ts: datetime | None = None @@ -104,6 +104,16 @@ class SystemLogService: ts = datetime.strptime(asctime, "%Y-%m-%d %H:%M:%S") except Exception: ts = None + # 尝试解析方括号格式日志: [2025-12-17 17:09:06] + elif line.startswith("["): + try: + # 提取第一个方括号内的时间戳 + end_bracket = line.find("]") + if end_bracket > 1: + time_str = line[1:end_bracket] + ts = datetime.strptime(time_str, "%Y-%m-%d %H:%M:%S") + except Exception: + ts = None parsed.append((ts, idx, line)) # 按时间戳排序(无时间戳的行排在最后,保持原始顺序) diff --git a/install.sh b/install.sh index e84599d7..dd598d6b 100755 --- a/install.sh +++ b/install.sh @@ -388,6 +388,21 @@ fi # 准备 HTTPS 证书(无域名也可使用自签) generate_self_signed_cert +# ============================================================================== +# 预拉取 Worker 镜像(避免扫描时等待) +# ============================================================================== +step "预拉取 Worker 镜像..." +DOCKER_USER=$(grep "^DOCKER_USER=" "$DOCKER_DIR/.env" 2>/dev/null | cut -d= -f2) +DOCKER_USER=${DOCKER_USER:-yyhuni} +WORKER_IMAGE="${DOCKER_USER}/xingrin-worker:${APP_VERSION}" + +info "正在拉取: $WORKER_IMAGE" +if docker pull "$WORKER_IMAGE"; then + success "Worker 镜像拉取完成" +else + warn "Worker 镜像拉取失败,扫描时会自动重试拉取" +fi + # ============================================================================== # 启动服务 # ==============================================================================