feat(docreader): add health check

This commit is contained in:
wizardchen
2025-09-10 20:12:37 +08:00
committed by lyingbug
parent 8a2b38da6f
commit 6f6ca84dae
4 changed files with 22 additions and 1 deletions
+8
View File
@@ -68,6 +68,8 @@ services:
condition: service_healthy
minio:
condition: service_started
docreader:
condition: service_healthy
networks:
- WeKnora-network
restart: unless-stopped
@@ -129,6 +131,12 @@ services:
- MINIO_BUCKET_NAME=${MINIO_BUCKET_NAME}
- MINIO_USE_SSL=${MINIO_USE_SSL}
- WEB_PROXY=${WEB_PROXY}
healthcheck:
test: ["CMD", "grpc_health_probe", "-addr=:50051"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
networks:
- WeKnora-network
restart: unless-stopped
+6
View File
@@ -114,7 +114,13 @@ RUN apt-get update && apt-get install -y \
libglu1-mesa \
libsm6 \
libreoffice \
curl \
&& rm -rf /var/lib/apt/lists/*
# 安装 grpc_health_probe
RUN GRPC_HEALTH_PROBE_VERSION=v0.4.24 && \
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
chmod +x /bin/grpc_health_probe
# 从构建阶段复制已安装的依赖和生成的代码
COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
+1
View File
@@ -1,5 +1,6 @@
grpcio
grpcio-tools
grpcio-health-checking
protobuf
python-docx
PyPDF2
+7 -1
View File
@@ -6,6 +6,8 @@ import traceback
import grpc
import uuid
import atexit
from grpc_health.v1 import health_pb2_grpc
from grpc_health.v1.health import HealthServicer
# Add parent directory to Python path
current_dir = os.path.dirname(os.path.abspath(__file__))
@@ -348,9 +350,13 @@ def serve():
],
)
# Register service
# Register services
docreader_pb2_grpc.add_DocReaderServicer_to_server(DocReaderServicer(), server)
# Register health check service
health_servicer = HealthServicer()
health_pb2_grpc.add_HealthServicer_to_server(health_servicer, server)
# Set listen address
server.add_insecure_port(f"[::]:{port}")