feat(health-check): add pipeline busy status to health endpoint

This commit is contained in:
yangdx
2025-03-26 12:41:49 +08:00
parent 57143fedcc
commit 1030068459

View File

@@ -421,37 +421,44 @@ def create_app(args):
@app.get("/health", dependencies=[Depends(combined_auth)]) @app.get("/health", dependencies=[Depends(combined_auth)])
async def get_status(): async def get_status():
"""Get current system status""" """Get current system status"""
username = os.getenv("AUTH_USERNAME") try:
password = os.getenv("AUTH_PASSWORD") pipeline_status = await get_namespace_data("pipeline_status")
if not (username and password):
auth_mode = "disabled" username = os.getenv("AUTH_USERNAME")
else: password = os.getenv("AUTH_PASSWORD")
auth_mode = "enabled" if not (username and password):
auth_mode = "disabled"
else:
auth_mode = "enabled"
return { return {
"status": "healthy", "status": "healthy",
"working_directory": str(args.working_dir), "working_directory": str(args.working_dir),
"input_directory": str(args.input_dir), "input_directory": str(args.input_dir),
"configuration": { "configuration": {
# LLM configuration binding/host address (if applicable)/model (if applicable) # LLM configuration binding/host address (if applicable)/model (if applicable)
"llm_binding": args.llm_binding, "llm_binding": args.llm_binding,
"llm_binding_host": args.llm_binding_host, "llm_binding_host": args.llm_binding_host,
"llm_model": args.llm_model, "llm_model": args.llm_model,
# embedding model configuration binding/host address (if applicable)/model (if applicable) # embedding model configuration binding/host address (if applicable)/model (if applicable)
"embedding_binding": args.embedding_binding, "embedding_binding": args.embedding_binding,
"embedding_binding_host": args.embedding_binding_host, "embedding_binding_host": args.embedding_binding_host,
"embedding_model": args.embedding_model, "embedding_model": args.embedding_model,
"max_tokens": args.max_tokens, "max_tokens": args.max_tokens,
"kv_storage": args.kv_storage, "kv_storage": args.kv_storage,
"doc_status_storage": args.doc_status_storage, "doc_status_storage": args.doc_status_storage,
"graph_storage": args.graph_storage, "graph_storage": args.graph_storage,
"vector_storage": args.vector_storage, "vector_storage": args.vector_storage,
"enable_llm_cache_for_extract": args.enable_llm_cache_for_extract, "enable_llm_cache_for_extract": args.enable_llm_cache_for_extract,
}, },
"core_version": core_version, "core_version": core_version,
"api_version": __api_version__, "api_version": __api_version__,
"auth_mode": auth_mode, "auth_mode": auth_mode,
} "pipeline_busy": pipeline_status.get("busy", False)
}
except Exception as e:
logger.error(f"Error getting health status: {str(e)}")
raise HTTPException(status_code=500, detail=str(e))
# Custom StaticFiles class to prevent caching of HTML files # Custom StaticFiles class to prevent caching of HTML files
class NoCacheStaticFiles(StaticFiles): class NoCacheStaticFiles(StaticFiles):